【发布时间】:2020-12-01 16:31:20
【问题描述】:
所以我有一个运行良好的脚本,我在网上找到并根据我的需要进行了更改。我在下面粘贴了这个脚本。但是,在输出中有许多对邮箱具有权限的禁用用户。例如。我会得到一个像“邮箱名称^Mailbox@email.com^ActiveUser ActiveUser DisabledUser”这样的输出所以我想知道是否有办法让脚本跳过禁用用户,就像它忽略自我权限一样。
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
. $env:ExchangeInstallPath\bin\RemoteExchange.ps1
Connect-ExchangeServer -auto
$OutFile = “C:\Send_As_Permissions.txt”
“DisplayName” + “^” + “Email Address” + “^” + “Send As” | Out-File $OutFile -Force
$Mailboxes = Get-Mailbox -resultsize unlimited | Select Identity, Alias, DisplayName, DistinguishedName, WindowsEmailAddress
ForEach ($Mailbox in $Mailboxes) {
$SendAs = Get-ADPermission $Mailbox.identity | where {($_.ExtendedRights -like “*Send-As*”) -and -not ($_.User -like “NT AUTHORITY\SELF”) -and -not ($_.User -like “s-1-5-21*”)} | % {$_.User}
$Mailbox.DisplayName + “^” + $Mailbox.WindowsEmailAddress + “^” + $SendAs | Out-File $OutFile -Append
}
【问题讨论】:
标签: powershell exchange-server-2010