User Profile
davidmi655
Copper Contributor
Joined 6 years ago
User Widgets
Recent Discussions
Re: Reclaiming licenses from deleted users
Laura Floeckher I have experienced this issue as well. Our de-provisioning process now includes removing the licenses, however some still slip through. So, I found a way to fix the issue: All of this part is done in PowerShell while connected and logged in to the MSOLService 1. Run the command Get-MsolUser –ReturnDeletedUsers | select UserPrincipalName,IsLicensed | export-csv <Some file path where you want the file> 2. Open the file in Excel, sort by IsLicensed and delete any that are False. Save the file 3. Paste the following script in to a text editor: Import-Csv <The file you created above> | foreach{ $UPN = $_.UserPrincipalName Restore-MsolUser -UserPrincipalName $UPN (get-MsolUser -UserPrincipalName $UPN).licenses.AccountSkuId | foreach{ $License = $_ echo "Removing license: $License" Set-MsolUserLicense -UserPrincipalName $UPN -RemoveLicenses $License } Remove-MsolUser -UserPrincipalName $UPN -Force } 4. Save the script after you updated it with the file name. Make sure you end the file name with .ps1 5. Run the script in PowerShell. The script reactivates the account, removes any license assigned to the account and then removes the account. You can run the command Get-MsolUser –ReturnDeletedUsers again afterwards to ensure all accounts now show False under IsLicensed.32KViews2likes2Comments
Recent Blog Articles
No content to show