iT邦幫忙

0

如何將所有Exchange通訊組的成員導出到文本文件

導出單一的通錄組到一個TXT文件裡。
Get-DistributionGroupMember | ft name, primarysmtpaddress >> C:\members.txt

https://ithelp.ithome.com.tw/upload/images/20171205/20107267LA6g3muqEd.jpg

請問!
如何導出『所有』的通錄組到一個TXT文件裡?
由於Exhange server剛升級至2016.Exchange的群組較Active Directory少。

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
jeles51
iT邦研究生 3 級 ‧ 2017-12-06 08:33:04
最佳解答

建立一個 ListMembers.ps1,內容如下:
執行後產出檔案C:\ListMembers.txt

$saveto = "C:\\ListMembers.txt"

Get-DistributionGroup | sort name | ForEach-Object {

	"`r`n$($_.Name)`r`n=============" | Add-Content $saveto
	Get-DistributionGroupMember $_ | sort Name | ForEach-Object {
		If($_.RecipientType -eq "UserMailbox")
			{
				$_.Name + " (" + $_.PrimarySMTPAddress + ")" | Add-Content $saveto
			}
	}
}

已實測在 Exchange 2010 可行.

參考自:
https://community.spiceworks.com/scripts/show/1388-export-distribution-list-members

看更多先前的回應...收起先前的回應...
totop007 iT邦新手 5 級 ‧ 2017-12-06 15:47:14 檢舉

不知道為何沒有輸出?
https://ithelp.ithome.com.tw/upload/images/20171206/20107267OivjOvxPST.jpg
https://ithelp.ithome.com.tw/upload/images/20171206/20107267vLnBH0KmNm.jpg

totop007 iT邦新手 5 級 ‧ 2017-12-06 15:47:15 檢舉

run with power shell.
然後很快地就自動關掉了

Ray iT邦大神 1 級 ‧ 2017-12-06 17:36:44 檢舉

你要用 Exchange EMS 去跑才行, 光叫 PowerShell 她不會載入 Exchange 模組...

jeles51 iT邦研究生 3 級 ‧ 2017-12-07 11:48:31 檢舉

如同 raytracy前輩所言,
EMS位於:
開始->所有程式->Microsoft Exchange Server xxxx->Exchange Management Shell

我要發表回答

立即登入回答