简体   繁体   English

PowerShell 获取通讯组报告的脚本

[英]PowerShell script to get distribution group report

I am looking for a PowerShell script to get a export Distribution Group with following Information.我正在寻找 PowerShell 脚本来获取包含以下信息的导出通讯组。

Group Display Name
Group Owner
Group Member
Last Activity Date
Member Count 
Received Email Count
Group ID

I am working on a script but it is returning error我正在编写脚本,但它返回错误

$groupmembers = foreach ($i in Get-DistributionGroup)
 {

    Get-DistributionGroupMember $i | select Display Name, @{n='Member';e={$i.DisplayName}}

}

Get-DistributionGroupMember returns an object of type ReducedRecipient which does not contain a fields called Display or Name - but it does contain a field called DisplayName - i think this is probably your issue. Get-DistributionGroupMember返回一个类型为 ReducedRecipient 的 object ,它不包含名为DisplayName的字段 - 但它确实包含一个名为DisplayName的字段 - 我认为这可能是你的问题。

If you dont want to read the docs, an easy way of seeing the members of an object is to use ConvertTo-Json.如果您不想阅读文档,查看 object 成员的一种简单方法是使用 ConvertTo-Json。 Temporarily add the line Get-DistributionGroupMember $i | ConvertTo-Json临时添加行Get-DistributionGroupMember $i | ConvertTo-Json Get-DistributionGroupMember $i | ConvertTo-Json inside your foreach loop above the command that is failing.在失败的命令上方的 foreach 循环内的Get-DistributionGroupMember $i | ConvertTo-Json It will output the entire ReducedRecipient Object in JSON format so you can easily read the available property names and their current values.它将 output 整个ReducedRecipient Object 格式为 JSON 以便您可以轻松读取可用的属性名称及其当前值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM