我有一个文本文件,其中包含我尝试获取managedby属性的通讯组列表。我尝试运行不同的命令,但似乎是一个语法问题(PowerShell相当新),因为我能够检索单个通讯组的managedby属性。当我将结果格式化并导出到csv文件时,我得到的是一堆数字。我是关于powershell Exchange Server 2008的。
答案 0 :(得分:0)
从名为groups.txt的平面文本文件开始:
Employees@company.com
Executives@company.com
$grouplist = Get-Content groups.txt | foreach {Get-DistributionGroup -Identity $_ | Select-Object PrimarySMTPaddress, ManagedBy}
$grouplist | Export-Csv -Path results.csv -NoTypeInformation
给出如下结果:
"PrimarySmtpAddress","ManagedBy"
"Employees@company.com","admin"
"Executives@company.com","admin"
$grouplist = Get-Content groups.txt | foreach {Get-DistributionGroup -Identity $_ | Select-Object PrimarySMTPaddress, ManagedBy}
Export-Csv -InputObject $grouplist -Path results2.csv -NoTypeInformation
导致:
"Count","Length","LongLength","Rank","SyncRoot","IsReadOnly","IsFixedSize","IsSynchronized"
"2","2","2","1","System.Object[]","False","True","False"
环境:Exchange 2013,Powershell 5.0,Windows 10 Tech Preview 3