Skip to content

Instantly share code, notes, and snippets.

@haircut
Created December 19, 2014 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haircut/2eb57d87310cdb0e436c to your computer and use it in GitHub Desktop.
Save haircut/2eb57d87310cdb0e436c to your computer and use it in GitHub Desktop.
Import-Module MSOnline
write-host Licensing Office 365 . . .
$user = Get-Content "OfficeCredU.txt"
$password = Get-Content "OfficeCredP.txt" | ConvertTo-SecureString
$credential = New-Object System.Management.Automation.PsCredential -ArgumentList $user,$password
Connect-MsolService -Credential $credential
$lg = import-clixml OfficeLicense.xml
#Add licenses
$lg | %{ $thisLG = $_ ; Get-MsolGroup | ?{ $_.DisplayName -eq $thisLG.Group } } | %{ get-msolgroupmember -GroupObjectId $_.ObjectId } | ?{ $user = $_; $user.IsLicensed -eq $false } | %{ $thisLG.Licenses | %{ Set-MsolUser -ObjectId $user.ObjectId -UsageLocation "US"; Set-MsolUserLicense -ObjectId $user.ObjectId -AddLicenses $_.Sku -LicenseOptions (New-MsolLicenseOptions -AccountSkuId $_.Sku -DisabledPlans $_.Disabled) } }
Get-MsolAccountSku | export-csv LicenseResult.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment