When an employee leaves the organization, it's essential to offboard them efficiently to prevent unauthorized access to company resources. Offboarding in Microsoft 365 involves tasks like disabling the user account, revoking licenses, and ensuring that data like email and files are either archived or transferred. In this guide, we’ll show you how to offboard users using both the Microsoft 365 Admin Center and Graph PowerShell, keeping things straightforward and user-friendly.
Automating the offboarding process ensures consistency and security. By automating steps like disabling user accounts and revoking access, you reduce the risk of data breaches and human error. Graph PowerShell offers a more scalable option, especially for organizations with high employee turnover, while the Admin Center provides a more manual but still effective approach for smaller operations.
Before you can begin offboarding users, ensure you have the correct permissions:
Install-Module Microsoft.Graph
Connect-MgGraph -Scopes "User.ReadWrite.All"
Option 1: Using the Admin Center
Note: Removing the license does not immediately remove their data; the mailbox and OneDrive data are retained for a grace period of 30 days by default.
How to convert user's mailbox to shared mailbox?
Option 2: Using Graph PowerShell
For organizations with many employees, PowerShell can help offboard users quickly and efficiently. Here’s how:
$params = @{
accountEnabled = $false
}
Update-MgUser -UserId "john.doe@contoso.com" -BodyParameter $params
$User = Get-MgUser -UserId "john.doe@contoso.com"
$Licenses = Get-MgUserLicenseDetail -UserId $User.Id
Set-MgUserLicense -UserId $User.Id -RemoveLicenses @($Licenses.SkuId)
Convert Mailbox to Shared Mailbox
Set-MgUserMailboxSettings -UserId $User.Id -MailboxType "Shared"
Transfer OneDrive Files:
Invoke-MgSharePointSiteDriveItemMove -SiteId "" -ItemId "" -TargetId ""
Get-MgUserMemberOf -UserId $User.Id | ForEach-Object {
Remove-MgGroupMember -GroupId $_.Id -UserId $User.Id
}
Remove-MgUser -UserId $User.Id
Option 1: Using the Admin Center:
Option 2: Using Graph PowerShell:
$disabledUsers = Get-MgUser -All -Filter "accountEnabled eq false"
$disabledUsers
Get-MgUserLicenseDetail -UserId $User.Id
Get-MgUserMemberOf -UserId $User.Id
Offboarding users efficiently in Microsoft 365 is vital for maintaining security and preventing unauthorized access. Whether you're using the Admin Center for smaller operations or Graph PowerShell for larger-scale tasks, automation can make the process smoother and reduce the likelihood of errors. The combination of disabling accounts, revoking licenses, and transferring data ensures a complete offboarding process.
© m365corner.com. All Rights Reserved. Design by HTML Codex