获取 Exchange 通讯组的注释

获取 Exchange 通讯组的注释

我想构建一个单行程序来获取特定分发组的注释并将其与分发组的名称和其他信息一起输出。我在谷歌上搜索过,发现不同的来源都有相同的解决方案。这是我找到的解决方案:

Get-DistributionGroup Head-of-Operations | Select-Object Name, GroupType, ManagedBy, @{Name="Notes";Expression={(Get-Group $_).Notes}}

这是其中一个来源:

https://richgski.blogspot.com/2012/03/powershell-get-exchange-distribution.html

但是带有注释的行始终保持空白,我不知道为什么:

Name        GroupType ManagedBy Notes
----        --------- --------- -----
Head-of-Ops Universal {}

当我单独执行以下命令时:

Get-Group Head-of-Ops | Select-Object Notes

...它给了我正确的注释作为输出:

Notes
-----
Owner- Paul J.

我现在对它进行了更多的尝试。以下代码运行正常:

$Result = Get-DistributionGroup Head-of-Operations
Get-Group $Result.Name | Select-Object Notes

输出:

Notes
-----
Owner- Paul J.

但这个仍然不起作用。它运行时没有任何错误,但 Notes 仍然是空白的:

Get-DistributionGroup Head-of-Operations | Select-Object Name,GroupType,ManagedBy,@{Name="Notes";Expression={(Get-Group $_.Name | Select-Object Notes)}}

输出:

Name        GroupType ManagedBy Notes
----        --------- --------- -----
Head-of-Ops Universal {}

之后我在这里找到了另一篇关于这个主题的帖子: https://www.oxfordsbsguy.com/2014/04/21/exchange-powershell-how-to-enumerate-distribution-lists-managers-and-members/#comment-4452

但仍然使用以下命令:

Get-DistributionGroup Head-of-Ops | Select-Object Name,GroupType,ManagedBy,@{Expression={(Get-Group $_.Name).Notes};Label="Notes"}

我仍然得到相同的输出,但没有任何注释......

Name        GroupType ManagedBy Notes
----        --------- --------- -----
Head-of-Ops Universal {}

我就是不明白 :/

你们中有人看到了这个问题并且可以指出我吗?

亲切的问候,

凯文·范蒂尔

答案1

我现在已经使用 -verbose 参数运行了此命令,我认为我离解决方案又近了一步。我认为在某个时候它只是缺少一个参数,但我不知道是哪一个。这是代码:(我用 * 星号标记了敏感信息)

Get-DistributionGroup Head-of-Ops@h***.com -Verbose | Select-Object Name,GroupType,ManagedBy,@{Name="Notes";Expression={(Get-Group $_.Name).Notes}} -Verbose
VERBOSE: [16:04:28.885 GMT] Get-DistributionGroup : Active Directory session settings for 'Get-DistributionGroup' are: View Entire Forest: 'False', Default Scope: 'h***.de', Configuration Domain Controller: 'H***.h***.de',
Preferred Global Catalog: '***.h***.h***.de', Preferred Domain Controllers: '{ ****.h***.h***.de, H***.h***.de }'
VERBOSE: [16:04:28.916 GMT] Get-DistributionGroup : Runspace context: Executing user: h***.de/Companies/H***/D***/User/IT Service/****, Executing user organization: , Current organization: , RBAC-enabled: Enabled.
VERBOSE: [16:04:28.916 GMT] Get-DistributionGroup : Beginning processing &
VERBOSE: [16:04:28.932 GMT] Get-DistributionGroup : Current ScopeSet is: { Recipient Read Scope: {{, }}, Recipient Write Scopes: {{, }}, Configuration Read Scope: {{, }}, Configuration Write Scope(s): {{, }, }, Exclusive Recipient
Scope(s): {}, Exclusive Configuration Scope(s): {} }
VERBOSE: [16:04:28.932 GMT] Get-DistributionGroup : Resolved current organization: .
VERBOSE: [16:04:28.932 GMT] Get-DistributionGroup : Searching objects "Head-of-Ops@h***.com" of type "ADGroup" under the root "$null".
VERBOSE: [16:04:28.932 GMT] Get-DistributionGroup : Previous operation run on domain controller 'H***.h***.de'.
VERBOSE: [16:04:28.932 GMT] Get-DistributionGroup : Previous operation run on domain controller 'H***.h***.de'.
VERBOSE: [16:04:28.932 GMT] Get-DistributionGroup : Preparing to output objects. The maximum size of the result set is "1000".

VERBOSE: [16:04:28.947 GMT] Get-DistributionGroup : Ending processing &
Name        GroupType ManagedBy Notes
----        --------- --------- -----
Head-of-Ops Universal {}

我认为问题隐藏在以下这一行:

VERBOSE: [16:04:28.932 GMT] Get-DistributionGroup : Searching objects "Head-of-Ops@h***.com" of type "ADGroup" under the root "$null".

有人知道它缺少了什么以及为什么吗?

相关内容