Created
December 19, 2014 03:58
-
-
Save haircut/2eb57d87310cdb0e436c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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