Tuesday, 4 August 2015

#O365 - Force delete user with DirSync

Force delete Office 365 active users

1. Run Windows Azure Active Directory Module for Windows PowerShell as administrator
2. To connect Office 365, type
  • Connect-MsolService
3. To disable dirsync, type
  •   Set-MsolDirSyncEnabled –EnableDirSync $false
(remember enable back the dirsync after delete user completed by type, Set-MsolDirSyncEnabled –EnableDirSync $true)

4. To check dirsync was fully disable, type
  • (Get-MSOLCompanyInformation).DirectorySynchronizationEnabled
(Enable and disable might take a while to complete. Please wait until the dirsync fully disable and continue next step)

5. To remove the active users, type
  • Remove-MsolUser –UserPrincipalName darren@Contoso.com
6. To remove all the active users, type
  •  Get-MsolUser | Remove-MsolUser -Force
Force delete Office 365 user from deleted users

1. Run Windows Azure Active Directory Module for Windows PowerShell as administrator
2. To connect Office 365, type
  • Connect-MsolService
3. To remove the deleted users, type
  • Remove-MsolUser -UserPrincipalName darren@Contoso.com -RemoveFromRecycleBin

or
  • Remove-MsolUser -UserPrincipalName darren@Contoso.com -RemoveFromRecycleBin -force
4. To remove all deleted users, type
  • Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force

No comments:

Post a Comment