在不同的域中获取 UPNSuffixes

问题描述

我想删除不同域中的所有 PNSUFFIXES。 我运行这段代码

$namedomaincontroller = (Get-ADDomainController -discover -Domain $ComboBox.selectedItem).name
Enter-PSSession $namedomaincontroller
$UPNSuffixes = Get-ADForest| select UPNSuffixes -ExpandProperty UPNSuffixes
$UPNSuffixes


Foreach ($GUPN in $UPNSuffixes)

{

$ComboBox2.Items.Add($GUPN);

}

    Exit-PSSession

但我正在做前一个,因为我在另一个域中使用一个用户,前一个没有运行并出现错误

解决方法

我想删除其他域中的所有 PNSUFFIXES。

使用 Set-ADForest 删除不同域的所有 UPNS 后缀。

Set-ADForest -Credential "Domain01\User01" -Identity fabrikam.com -UPNSuffixes $null

Identity 参数指定要修改的 Active Directory 林。

-凭据

指定用于执行此任务的用户帐户凭据。

如果代理凭据没有执行任务的目录级权限,Active Directory PowerShell 将返回终止错误。

清除所有值:

-UPNS 后缀 $Null