查詢出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 檔案

}




相關文章

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.