Jere's Techblog

Add License to all O365 Users trough Powershell

First of all you need to install the Powershell Module and Connect to the MSOnline Serivce

Install-Module MSOnline
Import-Module *
Connect-MsolService -Credential (get-credential)

You can get an overview of all Users trough this Command:

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“.

#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
}

Continue reading...