我收到错误“无法删除用户 ' [email protected] '。”在 Azure 和 Office 365 中出现错误“并非所有选定的用户都已删除。目前无法删除某些用户。相关 ID:”。
我已经与几位 O365 技术人员运行了以下命令,但它无法删除。它不在任何共享资源、联系人列表、dlist 等中。
PS C:\Users\owner> set-executionpolicy unrestricted
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
PS C:\Users\owner> $Cred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic –AllowRedirection
Import-PSSession $Session
PS C:\Users\owner> Remove-MsolUser -UserPrincipalName <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3d50587d484e584f135e5250" rel="noreferrer noopener nofollow">[email protected]</a>
Confirm
Continue with this operation?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
Remove-MsolUser : Unable to complete this action. Try again later.
At line:1 char:16
+ Remove-MsolUser <<<< -UserPrincipalName <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5c31391c292f392e723f3331" rel="noreferrer noopener nofollow">[email protected]</a>
+ CategoryInfo : OperationStopped: (:) [Remove-MsolUser], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InternalServiceException,Microsoft.Online.Adm
inistration.Automation.RemoveUser
PS C:\Users\owner> remove-msoldomain -domainname user.com -force
Remove-MsolDomain : Unable to remove this domain. Use Get-MsolUser -DomainName <domain name> to retrieve a list of obj
ects that are blocking removal.
At line:1 char:18
+ remove-msoldomain <<<< -domainname user.com -force
+ CategoryInfo : OperationStopped: (:) [Remove-MsolDomain], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.DomainNotEmptyException,Microsoft.Online.Admi
nistration.Automation.RemoveDomain
PS C:\Users\owner> get-msoluser -domainname user.com
UserPrincipalName DisplayName isLicensed
----------------- ----------- ----------
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84e9e1c4f1f7e1f6aae7ebe9" rel="noreferrer noopener nofollow">[email protected]</a> User A. Name False
PS C:\Users\owner> remove-msoluser -userprincipalname <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ef3fbdeebedfbecb0fdf1f3" rel="noreferrer noopener nofollow">[email protected]</a>
Confirm
Continue with this operation?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
Remove-MsolUser : Unable to complete this action. Try again later.
At line:1 char:16
+ remove-msoluser <<<< -userprincipalname <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bdd0d8fdc8ced8cf93ded2d0" rel="noreferrer noopener nofollow">[email protected]</a>
+ CategoryInfo : OperationStopped: (:) [Remove-MsolUser], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InternalServiceException,Microsoft.Online.Adm
inistration.Automation.RemoveUser
PS C:\Users\owner> remove-msoluser -userprincipalname <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="771a1237020412055914181a" rel="noreferrer noopener nofollow">[email protected]</a> -force
Remove-MsolUser : Unable to complete this action. Try again later.
At line:1 char:16
+ remove-msoluser <<<< -userprincipalname <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7e131b3e0b0d1b0c501d1113" rel="noreferrer noopener nofollow">[email protected]</a> -force
+ CategoryInfo : OperationStopped: (:) [Remove-MsolUser], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InternalServiceException,Microsoft.Online.Adm
inistration.Automation.RemoveUser
最佳答案
您可以尝试的两件事(按顺序):
- 使用
Set-MsolUserLicense
删除用户的所有许可证 将用户的域更改为其他域:
$user = Get-MsolUser -UserPrincipalName "user.com"
Set-MsolUserPrincipalName -ObjectId $user.ObjectId -NewUserPrincipalName "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d8b5bd98adabbdaaf6b7b6b5b1bbaab7abb7beacf6bbb7b5" rel="noreferrer noopener nofollow">[email protected]</a>"
首先尝试 (1),然后尝试删除。如果还是不行,执行(2),然后尝试删除。
关于powershell - Azure 用户删除错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20360137/