Tuesday, September 10, 2013

Use PowerShell to add users to Office 365

#Import-Module MSOnline
#$O365Cred = Get-Credential
#$O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection

#Import-PSSession $O365Session
#Connect-MsolService –Credential $O365Cred
 
#Get-MsolUser
$users = Get-Content "FOLDERLOCATION"
foreach ($user in $users)
{#we are splitting the values from the users file here. There are #three entries so we split the value on a comma

#and split into three sections; first name, middle initial and last #name

$split = $user.Split(",", 2)
$first = $split[0];
$last = $split[1];
$display = $first + " " + $last

#get the first letter of the first name so we can create alias

$firstletter = $first.substring(0,1)
$alias = $firstletter + $last
$upn = $first + "." + $last + "@COMPANYNAME.onmicrosoft.com"

New-MsolUser -UserPrincipalName $upn -DisplayName $display -FirstName $first -LastName $last -UsageLocation "US" -LicenseAssignment "ENVIRONMENTNAME:ENTERPRISEPACK" -Password "Password!"

}

Thursday, April 11, 2013

List the most used OSes in your Hyper-V environment

Get-SCVirtualMachine -vmhost hostname | Group-Object OperatingSystem | Sort Count -Descending | Select Name, Count