First of all you need to install the Powershell Module and Connect to the MSOnline Serivce
1 2 3 |
Install-Module MSOnline Import-Module * Connect-MsolService -Credential (get-credential) |
You can get an overview of all Users trough this Command:
1 |
Get-MsolUser |
This script block can be used to assign a license to any user who is not a licensed user.
This example assumes that the command “(Get-MsolAccountSku).accountskuid” retrive only one value/license. If you have several licenses you have to specify this for the variable “$SKUID“.
1 2 3 4 5 6 7 8 9 10 11 |
#byJKU 29.04.2019 #Activate each user with MSolAccountSKU License $SKUID= (Get-MsolAccountSku).accountskuid IF ((Get-MsolUser -UnlicensedUsersOnly).UserPrincipalName){ (Get-MsolUser -UnlicensedUsersOnly).UserPrincipalName | % { Set-MsolUserLicense -UserPrincipalName $_ -AddLicenses $SKUID } }Else{ Write-host "There is no User without License" -ForegroundColor Yellow } |
0