我有这个oneliner将Outlook 365日历bookinpolicy从x.500格式转换为实际的人类可读名称:
((Get-CalendarProcessing dept-calendar-*).BookInPolicy | Get-DistributionGroup).name
我无法弄清楚的是如何同时显示原始日历名称?现在我得到了名字,但没有提到它属于哪个日历,例如:
dept-calendar-bookinpolicy-mgr
dept-calendar-bookinpolicy25-mgr
dept-calendar-bookinpolicy98-mgr
我希望它看起来像这样:
dept-calendar-room1
dept-calendar-bookinpolicy-mgr
dept-calendar-room6
dept-calendar-bookinpolicy25-mgr
dept-calendar-room8
dept-calendar-bookinpolicy98-mgr
括在括号中就像使用Select-Object -ExpandProperty
所以你必须插入一个ForEach-Object
Get-CalendarProcessing dept-calendar-* | ForEach-Object{
$_.BookInPolicy
($_.BookInPolicy | Get-DistributionGroup).Name
""
}
在我的帮助下,我能够找到一种方法来做到这一点,所以我想我会回答我自己的问题:
(Get-CalendarProcessing dept-calendar-*) | ForEach-Object { $_ | Add-Member NoteProperty "BookInPolicy_Group" "" -Force; if(-not [String]::IsNullOrWhiteSpace($_.BookInPolicy)){$_.BookInPolicy_Group = ($_.BookInPolicy | Get-DistributionGroup).Name} Write-Output $_} | Select-Object Identity,BookInPolicy_Group | Format-List
我能用上面的东西得到我想要的东西。
Identity : dept-calendar-room1
BookInPolicy_Group : dept-calendar-bookinpolicy-mgr
Identity : dept-calendar-room6
BookInPolicy_Group : dept-calendar-bookinpolicy25-mgr
Identity : dept-calendar-room8
BookInPolicy_Group : dept-calendar-bookinpolicy98-mgr
希望这将有助于下一个人。