Remove toàn bộ user & group khỏi Azure AD
Nguồn: http://www.ms4u.info/2015/03/bulk-remove-azure-active-directory-user.html
Cập nhật:
[Scenario]
- Using Azure Active Directory
- Has used AAD Sync to sync on-premise user account and group
- Discovered has accidently sync user account and group to Azure Active Directory but require to remove it.
It’s quite a painful experience to delete each individual user account and group from Azure Management Portal. Wonder why no multiple select option and quite annoying when it asking for confirmation and refresh. But lucky enough got powershell to do the job.
[Pre-requisite]
- Install Microsoft Online Services Sign-In Assistant for IT Professionals RTW
- Install Azure Active Directory Module for Windows PowerShell (64-bit version),
[ Configuration]
After install the pre-requisite, open the Azure Active Directory Module for Windows Powershell.
Connect to Azure Active Directory by entering the Global Administrator account.
$msolcred = get-credential
connect-msolservice -credential $msolcred
|
Export the user account to csv file format
PS C:\> Get-AzureADUser -All 1 | Export-CSV C:\users.csv
PS C:\> Get-AzureADGroup -All 1 | Export-CSV C:\groups.csv
Then...
PS C:\> Import-CSV C:\users.csv | Remove-AzureADUser
PS C:\> Import-CSV C:\groups.csv | Remove-AzureADGroup
PS C:\> Get-AzureADGroup -All 1 | Export-CSV C:\groups.csv
Then...
PS C:\> Import-CSV C:\users.csv | Remove-AzureADUser
PS C:\> Import-CSV C:\groups.csv | Remove-AzureADGroup
Comments
Post a Comment