Solved

How to remove office 365 license

Posted on 2016-09-09
6
33 Views
Last Modified: 2016-09-09
Hello Experts,

I need to remove the licenses from my o365 users nightly. (I'll tell why if asked.)
I was trying to use this:
$x = Get-MsolUser -All  | where {$_.isLicensed -eq $true}; $x | foreach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "tenant:PROJECTCLIENT_GOV"}

Which should work, but looks ugly failing on 700 accounts and succeeding on the 35 that actually have licenses.
How can I change this statement to return only account licensed to use tenant:PROJECTCLIENT_GOV?

Thanks,
Keith
0
Comment
Question by:glo-nsa
6 Comments
 
LVL 14

Expert Comment

by:Edward Pamias
ID: 41791378
There are a few ways to do this, one is to create a text file and put in the account names then run a powershell script which will handle the rest. See link below from Microsoft with the correct powershell scripts to run.

Click here.
0
 
LVL 14

Expert Comment

by:Todd Nelson
ID: 41791393
Take a look at these references.  The first is for assigning licenses but the foundation is there to remove licenses and license options as well.

https://oddytee.wordpress.com/2016/06/28/assign-subscription-licenses-and-license-options-to-office-365-users/

https://oddytee.wordpress.com/2015/06/10/references-add-office-365-licenses-with-powershell/

Let us know.
0
 

Author Comment

by:glo-nsa
ID: 41791502
The syntax for removing I have down. What I am needing is the filter for only users that already have the named license.

I think there should be a filter condition on the back of this statement:
$x = Get-MsolUser -All  | where {$_.isLicensed -eq $true}

Thoughts?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 38

Accepted Solution

by:
Vasil Michev (MVP) earned 500 total points
ID: 41791512
You can filter by license SKU via:

Get-MsolUser -All | ? {$_.Licenses.AccountSkuId -eq "tenant:PROJECTCLIENT_GOV"}

Open in new window


or whatever the SKU is.
0
 
LVL 14

Expert Comment

by:Todd Nelson
ID: 41791518
You can do that to get all of the users that are assigned a license.  Have you tried that?
0
 

Author Closing Comment

by:glo-nsa
ID: 41791533
Perfect! Concise and with relevant example.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
If you don't know how to downgrade, my instructions below should be helpful.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now