Find unlicensed users with powershell in Office 365 and apply a license.

If you have many users synced to Office 365. It will be more efficient to user powershell to license them.

This is how:

connect-msolservice and enter crendentials.

Get-MsolAccountSku will display the license types.
And then:
$AccountSkuId =
$UsageLocation =
$LicenseOptions =
New-MsolLicenseOptions -AccountSkuId
$Users =
Get-MsolUser -All
| Where-Object
-like “false”}
$Users |
ForEach-Object {
Set-MsolUser -UserPrincipalName
-UsageLocation $UsageLocation
Set-MsolUserLicense -UserPrincipalName
-AddLicenses $AccountSkuId
-LicenseOptions $LicenseOptions

$users part find all Unlicensed users and apply a license to them.

Save it so .ps1 and run!

Enjoy powershell!

Author: Harri Jaakkonen

Leave a Reply

Your email address will not be published. Required fields are marked *