Avatar of John Davies
John DaviesFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

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
PowershellMicrosoft 365

Avatar of undefined
Last Comment
John Davies
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria image

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.
Avatar of John Davies
John Davies
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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
Avatar of John Davies
John Davies
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

For example if I want to remove all these if they are there and ignore if they are not.
Plan1.png
ASKER CERTIFIED SOLUTION
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of John Davies
John Davies
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Totally excellent again. Thanks for your help ;-)
Powershell
Powershell

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

27K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo