Forum Discussion
dannytveria
May 05, 2021Brass Contributor
Remove licenses from users office 365
Hi, I trying with no success to remove licenses from users. I tried script from Microsoft docs but it`s not working. I created txt file with the user upn. after I runned the script I gettin...
Schnittlauch
Steel 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.
Schnittlauch
May 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"
}