Я хотел бы вывести каждого пользователя, имеющего разрешение SendAs для почтового ящика. Однако я хотел бы использовать primarySMTPAddress в качестве идентификатора, который не отображается в командлете Get-ADPermission.Как получить PrimarySMTPAddress при запуске Get-ADPermission
Как я могу изменить эту строку кода, чтобы сделать это:
$SendAs = Get-ADPermission $Mailbox.DistinguishedName | ? {$_.ExtendedRights -like "Send-As" -and $_.User -notlike "NT AUTHORITY\SELF" -and !$_.IsInherited} | % {$_.User}
Я пытался что-то вроде этого, но безрезультатно:
$SendAs = Get-ADPermission $Mailbox.DistinguishedName | ? {$_.ExtendedRights -like "Send-As" -and $_.User -notlike "NT AUTHORITY\SELF" -and !$_.IsInherited} | % {$_.User}
$sendAs| %{$uSendAs += ($(if($uSendAs){";"}) + (Get-mailbox $_))}
Я пытаю включить его в этот сценарий :
$OutFile = "C:\scripts\export.txt"
"DisplayName" + "," + "Alias" + "," + "Primary SMTP" + "," + "Full Access" + "," + "Send As" + "," + "Send on Behalf" | Out-File $OutFile -Force
$Mailboxes = Get-Mailbox -ResultSize:Unlimited | Select Identity, Alias, DisplayName, DistinguishedName, primarysmtpaddress
ForEach ($Mailbox in $Mailboxes)
{
$SendAs = Get-ADPermission $Mailbox.DistinguishedName | ? {$_.ExtendedRights -like "Send-As" -and $_.User -notlike "NT AUTHORITY\SELF" -and !$_.IsInherited} | % {$_.User}
$FullAccess = Get-MailboxPermission $Mailbox.Identity | ? {$_.AccessRights -eq "FullAccess" -and !$_.IsInherited} | % {$_.User}
$sendbehalf=Get-Mailbox $Mailbox.Identity | select-object -expand grantsendonbehalfto | select-object -expand rdn | % {$_.User}
if (!$SendAs -and !$FullAccess -and !$sendbehalf){continue}
$Mailbox.DisplayName + "," + $Mailbox.Alias + "," + $Mailbox.primarysmtpaddress + "," + $FullAccess + "," + $SendAs + "," + $sendbehalf | Out-File $OutFile -Append
}