Max_Power Posted November 2, 2016 Posted November 2, 2016 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
jaminben Posted November 2, 2016 Posted November 2, 2016 (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 November 2, 2016 by jaminben 1
Davit2005 Posted November 2, 2016 Posted November 2, 2016 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" } 1
Arthur Posted November 2, 2016 Posted November 2, 2016 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?
NetworkNinja Posted November 3, 2016 Posted November 3, 2016 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.
darkest_star Posted November 7, 2016 Posted November 7, 2016 If you have quite a bit of licencing changes to do or just want an over view of licences then I find this utility works really well: https://gallery.technet.microsoft.com/Office365-License-cfd9489c/view/Discussions Its worked a treat for me to remove licence features for a large number of users. 1
Max_Power Posted November 7, 2016 Author Posted November 7, 2016 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now