导出共享邮箱的成员

今天同事让我帮忙写个脚本导出下列的属性。脚本没什么难度,关键是不知道通过哪个命令找,比如:成员通过Get-MailboxPermission获得,注释通过Get-User获得。

$pw = ConvertTo-SecureString 'your_pwd' -AsPlainText -Force
$creds = New-Object -Typename System.Management.Automation.PSCredential -Argumentlist 'admin@company.cn', $pw
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://partner.outlook.cn/PowerShell -Credential $creds -Authentication Basic -AllowRedirection
Import-PSSession $ExchangeSession

Get-Mailbox | where RecipientTypeDetails -EQ "SharedMailBox" | foreach {
    [PSCustomObject]@{'Name'=$_.name; 'Comments'=(Get-User $_.name).notes; 'Members'=$null} | Export-Csv -Path f:\report.csv -Encoding Default -Append
    Get-MailboxPermission $_.name | where user -Like *vob* | foreach {
       [PSCustomObject]@{'Name'=$null; 'Comments'=$null; 'Members'=$_.user} | Export-Csv -Path f:\report.csv -Encoding Default -Append
    } 
}

 

posted @ 2015-08-07 17:06  dongdonggeorge  阅读(535)  评论(0编辑  收藏  举报