Hello,
To bulk assign licenses to all unlicensed users using PowerShell, you can follow these steps:
1.Connect to Microsoft 365: First, you need to connect to Microsoft 365 with PowerShell. You can use the Microsoft Graph PowerShell SDK for this purpose. Run the following command to connect:
Connect-Graph -Scopes User.Read.All
2.Get Unlicensed Users: Next, you need to get a list of all unlicensed users. You can use the following command to retrieve this list:
$unlicensedUsers = Get-MsolUser -All | Where-Object { $_.isLicensed -eq $false }
3.Assign Licenses: Finally, you can assign licenses to these unlicensed users. Replace <AccountSkuId> with your actual AccountSkuId. Use the following command to assign the licenses:
foreach ($user in $unlicensedUsers) {
Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -AddLicenses "<AccountSkuId>"
}
This script will loop through all unlicensed users and assign the specified license to each of them.