Then, for each individual license we can go ahead and run the Set-MsolUserLicense cmdlet. If said variable is empty, say because the user has no licenses assigned or no matching user was found, we skip to the next user. Thus, for each user we will first run the Get-MsolUser cmdlet and gather the list of currently assigned SKUs and store them in the $SKUs variable. The only tricky part is that we actually need to have a list of licenses to remove, as there is no -RemoveAllLicenses switch or similar. Once we have the list of users, the task of removing licenses is a simple one. You can use other properties as necessary, but make sure to adjust the code below to account for that, as it expects to see a column named UserPrincipalName in the input CSV file. The UserPrincipalName or ObjectId properties should do. The important thing is that you have at least one column that designates users unambiguously. You can easily prepare such by using the Get-MsolUser cmdlet and filtering out users based on specific criteria, or you can just populate it manually via Excel. The first step is to make sure we have a proper input file. Since this is a question I’ve seen asked previously, I decided to write a quick blog post about it and add some additional notes besides the actual code. A recent question over at the Spiceworks community asked for a PowerShell sample that will go over a list of Office 365 users imported via CSV file and remove all licenses for each user.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |