Get-MailboxSendAs-Query
Exchange Online: Query-format list of mailbox SendAs permissions
#Requires -Version 5.1
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$MailboxId
)
Process {
try {
$users = Get-RecipientPermission -Identity $MailboxId -ErrorAction Stop | Select-Object -ExpandProperty Trustee | Get-Mailbox -SortBy DisplayName -ErrorAction SilentlyContinue | Select-Object DisplayName, UserPrincipalName
foreach ($itm in $users) {
[PSCustomObject]@{
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Value = $itm.UserPrincipalName
DisplayValue = $itm.DisplayName
}
}
}
catch { throw }
}User principal name of the mailbox