In Need of a Script

Does anyone have a Powershell script that will remove ExchangeOnline licenses from users who have not used their license in the last XX days? I have a lot of users who have not used the ExchangeOnline license from the lastloggedin report and need to release the licenses.

This could either read directly of the system of preferably off the lastloggedin report CSV

Want them to keep sharepoint, just want to remove Exchange

Thanks in Advance for help

John
John DaviesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vasil Michev (MVP)Commented:
The Inactivity reports arent that accurate, I wouldnt necessarily trust them. Also, removing their EO license will not free up anything, as you are playing for the full plan, this will only have effect if you have purchased the standalone EO plan, and not E1/E3/E5/etc.

Otherwise, it's relatively easy to do this, you can try something like:

$csv = Import-csv blabla.csv
$plan =New-MsolLicenseOptions -AccountSkuId tenant:ENTERPRISEPACK -DisabledPlans "EXCHANGE_S_ENTERPRISE"

$csv | % { Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions $plan }

Open in new window


where the CSV is expected to have a column named $_.UserPrincipalName to designate the user and you have replaced the SKU id/plan as necessary.
John DaviesAuthor Commented:
Hi Vasil, how are you?

Thanks for this, some licenses have, azure, office etc, posted an image. How can I remove all and just leave the sharepoint? Effectively disabling exchange, Azure, Office ProPlus etc.

Thanks Again

John
Plans.png
John DaviesAuthor Commented:
For example if I want to remove all these if they are there and ignore if they are not.
Plan1.png
Vasil Michev (MVP)Commented:
Just adjust the plan option accordingly:

$plan =New-MsolLicenseOptions -AccountSkuId tenant:ENTERPRISEPACK -DisabledPlans "EXCHANGE_S_ENTERPRISE","OFFICESUBSCRIPTION","RMS_S_ENTERPRISE"

Open in new window


and so on. A full list can be obtained via:

(Get-MsolAccountSku | ? {$_.AccountSkuId -eq "tenant:ENTERPRISEPACK"}).ServiceStatus

Open in new window


or here: https://blogs.technet.microsoft.com/treycarlee/2014/12/09/powershell-licensing-skus-in-office-365/

Again, you will not actually free any licenses by doing this.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John DaviesAuthor Commented:
Totally excellent again. Thanks for your help ;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.