查詢出Exchange Server的通訊群組,並將通訊群組成員輸出到本地的文字檔中!,

來源:互聯網
上載者:User

查詢出Exchange Server的通訊群組,並將通訊群組成員輸出到本地的文字檔中!,

最近客戶有一個需求,希望查詢所有通訊群組的成員,這個使用PS 來做的話會比較簡單,怎麼做?代碼如下:

此POWERSHELL 在exchange 2010 執行通過!

param
(
$temppath="c:\log"

#定義日誌輸出路徑
)

if(!(Test-Path $temppath))

#判斷日誌路徑是否存在,如果不存在則建立目錄
{
New-Item -Path $temppath

#建立日誌路徑
}

$groupNum=get-distributiongroup

#將所有通訊群組輸出到一個變數

Set-Location $temppath

#變更命令執行路徑
foreach($groupnow in $groupNum)

#迴圈通訊群組
{
$groupmember=get-distributiongroupmember -identity $groupnow.name|select name

# 輸出通訊群組成員,並且只輸出名字
$tmppath=$temppath+"\"+$groupnow+".csv"

#定義輸出的通訊群組成員匯出的檔案
$groupmember |Export-Csv -Path $tmppath
#將通訊群組成員匯出為csv 檔案

}




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.