Home Uncategorized Delete Orphaned Groups and Users in 365 Azure

Delete Orphaned Groups and Users in 365 Azure

8
0

Delete Orphaned Group
Scenario
: You used to sync between local AD and cloud Azure AD but now you do not. You have local groups which you no longer need and now there are orphaned cloud groups which you cannot delete using the GUI because they are expected to be managed locally and synced.

You will need to be a Global Admin and use a PowerShell command to remove these objects.

Open an Elevated PowerShell Command window, then run some commands. If you already have the Azure Active Directory module below you can skip the install command.

Install-Module -Name MSOnline
Connect-MsolService
Get-MsolGroup

^This shows you all your groups.

Get-MsolGroup -SearchString "DisplayName" | Remove-MsolGroup

^This removes the group.

Run Get-MsolGroup again to see the remaining groups or refresh your view of the groups in the GUI to see if the one you deleted is gone.

See: How To Delete Orphaned Groups in Azure AD PowerShell (prajwaldesai.com) for more information.

 

Delete Orphaned User
To delete an orphaned user the process is similar, you just need to disable directory sync before deleting the object:

Set-MsolDirSyncEnabled –EnableDirSync $false
(Get-MSOLCompanyInformation).DirectorySynchronizationEnabled

^Run this until it returns “False”, then delete the user through the portal or PowerShell.

Set-MsolDirSyncEnabled -EnableDirSync $true

^Enable the sync service..

See: Couldn’t Delete this user because the account is synchronized (prajwaldesai.com) for more information.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here