In Need of a Script

John Davies
John Davies used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Distinguished Expert 2018

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.

Author

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

Author

Commented:
For example if I want to remove all these if they are there and ignore if they are not.
Plan1.png
Most Valuable Expert 2015
Distinguished Expert 2018
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.

Author

Commented:
Totally excellent again. Thanks for your help ;-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial