简体   繁体   中英

Powershell script that lists all (group)mailboxes of a certain exchange Database and all permissions expressed by primary SMTP

I am using Exchange 2010 and my domain only has Windows 2003 DC's

I need a Powershell script that lists all (group)mailboxes of a certain exchange Database in a csv file, and for each mailbox, provides the following information:

  • displayname
  • primary SMTP address from the mailbox
  • all existing alliasses from the mailbox
  • primary smtp address of the owner of the mailbox
  • primary smtp address of all the members who have read access permission on the mailbox
  • primary smtp address of all the members who have send-as permission on the mailbox
  • primary smtp address of all the members who have full access permission on the mailbox

I already wrote a little program that is a good start but I can't get my member users expressed on their primary SMTP address:

Here is the example:

$OutFile = "<Certain path>\<filename>_" + $(Get-Date -Format 'dd_MM_yyyy HH_mm tt') + ".csv"

"DisplayName" + "," + "EmailAddresses" + "," + "Full Access" + "," + "Send As" + "," + "ReadPermission" | Out-File $OutFile -Force

$Mailboxes = Get-Mailbox -Database "<Certain Database>" -ResultSize "Unlimited" | Select DistinguishedName, Identity, DisplayName, EmailAddresses
ForEach ($Mailbox in $Mailboxes) {
    $SendAs = Get-ADPermission $Mailbox.DistinguishedName | ? {$_.ExtendedRights -like "Send-As" -and $_.User -notlike "NT AUTHORITY\Self" -and !$_.IsInherited} | % {$_.User}      
    $FullAccess = Get-MailboxPermission $Mailbox.Identity | ? {$_.AccessRights -eq "FullAccess" -and !$_.IsInherited} | % {$_.User}         
    $ReadPermission = Get-MailboxPermission $Mailbox.Identity | ? {$_.AccessRights -eq "ReadPermission" -and !$_.IsInherited} | % {$_.User}         

    $Mailbox.DisplayName + "," + $Mailbox.EmailAddresses + "," + $FullAccess + "," + $SendAs + "," + $ReadPermission | Out-File $OutFile -Append
} 

Can someone help me out to find the requested result, or does anyone have another script that does the same ?

Thanks

首先重新编写创建PS Custom对象所需的内容,然后使用export-csv从中创建输出文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM