跨域交换获取邮箱 2007

get-mailbox across domains exchange 2007

当我在下方执行 运行 命令时,它可以正常工作

get-mailbox -identity xxx.xxx@domain .com

当我尝试 运行 脚本中的相同命令时,它不断出现无法在域控制器上找到的错误

$users = Import-Csv "C:\Users\xx\Documents\CSV\PORB.csv" foreach ($user in $users) { $Recipients = Get-Mailbox -Identity $user.users [array]$AllEmailAddresses = $Recipient.EmailAddresses [array]$NoX500Addresses = $Recipient.EmailAddresses | Where {$_ -notlike "X500:*"} Set-Mailbox -Identity $Recipient.Identity -EmailAddresses $NoX500Addresses

我得到的错误:Get-Mailbox:无法执行操作,因为在域控制器上找不到对象 'd.j@domain.com' 'XXX.aaa.bbbb.ccc.net'。 在 line:5 char:19 + $Recipients = Get-Mailbox -Identity $user.users }

**我不确定我做错了什么我还包括** $AdminSessionADSettings.ViewEntireForest = $true

在网上找到另一个脚本来获取域列表并对列表中的每个域进行操作

$objForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() $DomainList = @($objForest.Domains | Select-Object Name) $Domains = $DomainList | foreach {$_.Name}

对每个领域采取行动

foreach($Domain in ($Domains)){ $users = Import-Csv "C:\Users\ramer\Documents\CSV\PORB.csv" foreach ($user in $users) { $Recipients = Get-Mailbox -Identity $user.users [数组]$AllEmailAddresses = $Recipient.EmailAddresses [数组]$NoX500Addresses = $Recipient.EmailAddresses |哪里{$_ -notlike "X500:*"} Set-Mailbox -Identity $Recipient.Identity -EmailAddresses $NoX500Addresses}