Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to remove office 365 license

Posted on 2016-09-09
6
Medium Priority
?
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 19

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 16

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 43

Accepted Solution

by:
Vasil Michev (MVP) earned 2000 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 16

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
how to add IIS SMTP to handle application/Scanner relays into office 365.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

650 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