我正在使用交换外壳从Office 365安装程序中提取邮箱的委托详细信息。
问题是我在邮箱的GrantSendOnBehalfTo属性中获取用户的显示名称,该属性不是唯一的值。如何在GrantSendOnBehalfTo属性中打印用户的唯一ID?
答案 0 :(得分:0)
我目前无法对此进行测试,但是我认为这可能会有所帮助:
$SendOnBehalf = Get-Mailbox -Identity 'testing' | Select-Object -ExpandProperty GrantSendOnBehalfTo
foreach ($user in $SendOnBehalf) {
try {
# get the user or group that has SendOnBehalf permissions
$sob = Get-User -Identity $user -ErrorAction SilentlyContinue
if ($sob) {
Write-Host "User: $($sob.SamAccountName)" # or use $($sob.WindowsEmailAddress) if that is more unique for you
}
else {
$sobGroup = Get-Group -Identity $user -ErrorAction SilentlyContinue
Write-Host "Group: $($sob.SamAccountName)"
}
}
catch {}
}