Jump to content

Recommended Posts

Posted

I need to remove the current licences assigned to students in Office 365 for student advantage and replace them with new licences as we have changed our MS agreement and the old one is about to expire.

 

I can run individual lines in powershell to remove the licences but is there a way to do this in bulk if i have a csv of all users? Struggling to find any commands that works.

 

Command I'm running for individual licences is;

Set-MsolUserLicense -UserPrincipalName username@domain -RemoveLicenses "SCHOOLNAME:OFFICESUBSCRIPTION_STUDENT"

 

Thanks in advance

Posted (edited)

I'm just quickly guessing but something like the below will feed from a .csv.

 

$users = Import-Csv C:\Powershell\Office_365\userlist.csv

foreach ($user in $users)
   {
       Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -RemoveLicenses "SCHOOLNAME:OFFICESUBSCRIPTION_STUDENT"
   }

 

Where UserPrincipalName is the column header.

Edited by jaminben
  • Thanks 1
Posted

Not tested but I use the similar script to assign license to users but I guess it could be reversed using the -RemoveLicenses command you have specified.

 

The idea being to get a list of licensed users and export to a file, hash the Return command once you are happy with the exported csv

 

Get-MsolUser -LicensedUsersOnly -All | Select UserPrincipalName,displayName | Export-Csv LicensedExport.csv -Notypeinformation

 

# Hash below line to remove the licenses

Return

 

# Import the CSV of Non-Licensed Users

$Licenserows = import-csv "LicenseExport.csv"

 

# Remove license User Beginning Loop

 

 

ForEach ($row in $Licenserows) {

 

$UnLicensedUPN = $row.UserPrincipalName

$UserName = $row.displayName

Set-MsolUserLicense -UserPrincipalName $UnLicensedUPN -RemoveLicenses "SCHOOLNAME:OFFICESUBSCRIPTION_STUDENT"

}

  • Thanks 1
Posted
I need to remove the current licences assigned to students in Office 365 for student advantage and replace them with new licences as we have changed our MS agreement and the old one is about to expire.

Unless I have misunderstood the question, surely you wouldn't need to remove and add the exact same license to students again? You would just add the new product key for the license in the admin portal? :confused:

Posted

If you still need any help with this i might be able to. We have a code which we use to change all licenses for all users in office 365.

 

I would post on here but i can't seem to find the part where you can copy and paste code.

Posted

Thank you - managed to get licences removed and new ones added using slightly amended versions of codes written above.

 

Ediy * downloading the utility and will give that a try as well.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...