Forum Discussion
Remove licenses from users office 365
Hi dannytveria,
sounds like this:
https://community.spiceworks.com/topic/1499908-powershell-office-365-change-multiple-user-passwords
- dannytveriaMay 06, 2021Copper Contributor
- SchnittlauchMay 06, 2021Steel Contributor
Hi dannytveria,
$_.UserPrincipalName is null. Do you have a list of the users, you want to remove the licenses? (Maybe they are all in the same AD Group, idk.)
If yes, than go and make their own variable ($Students for example) to remove ther licenses instead of $_.UserPrincipalName.Im wondering why the variable is null.
- SchnittlauchMay 06, 2021Steel Contributor
dannytveria Otherwise you can try it with an foreach loop something looking like this
$UserCSV = import-csv -path C:\Users\Schnittlauch\AllUsersInACsvFile.csv
foreach ($user in $UserCSV.ColumnWithTheUsers)
{
Set-MsolUserLicense -UserprincipalName $user -removeLicenses "oranimlive:STANDARDWOFFPACK_IW_STUDENT"
}