如果是通過AAD方式同步的話,在AAD中使用者是無法删除的,是以需要關閉。
一.安裝AzureAD子產品失敗
PS C:\Users\administrator> Install-Module AzureAD
The term 'Install-Module' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:15
+ Install-Module <<<< AzureAD
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
解決:安裝Windows Management Framework 5.1
下載下傳位址為https://www.microsoft.com/en-us/download/confirmation.aspx?id=54616
下載下傳 Windows Management Framework 5.1後,安裝。
二.運作Install-Module AzureAD
PackageManagement\Install-PackageProvider : No match was found for the specified search criteria for the provider
'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package
has the tags.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7405 char:21
+ ... $null = PackageManagement\Install-PackageProvider -Name $script:N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pac
kageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider
解決:指定傳輸協定,PS中運作如下:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
三.登入
PS C:\Users\administrator> Connect-MsolService -AzureEnvironment AzureCloud
輸入使用者名和密碼,注意後面的AzureCloud,如果不是全球版,需要換成AzureChinaCloud
四.關閉同步
PS C:\Users\administrator> Set-MsolDirSyncEnabled -EnableDirSync $false
關閉同步後再登入Azure Portal,可以看到同步已經disable了。
五.登入Azure.portal.com 就可以删除使用者了