An Engineers Notebook

How to disable SharePoint Online Access for a specific department in Office 365 using PowerShell

This PowerShell script will disable access to SharePoint online services for all HR department staff


Import-Module MSOnline

$cred = Get-Credential
Connect-MsolOnline -Cred $cred
$licence = New -MsolUserLicenceOptions -AccountSkuID “techshizz:STANDARDPACK”
Get-MsolUser -All -Department “HR” | Set-MsolUserLicence -LicenceOptions $Licence

Leave a Reply

Your email address will not be published.