Get-MailboxSendOnBehalf-Query
Exchange Online: Query-format list of mailbox SendOnBehalf permissions
#Requires -Version 5.1
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$MailboxId
)
Process {
try {
$grantList = (Get-Mailbox -Identity $MailboxId -ErrorAction Stop).GrantSendOnBehalfTo
$users = $grantList | 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