none
Powershell Script For Specific Email Domain Mailbox with Size and Export to CSV RRS feed

  • Question

  • Hello All

    We have several email domains, within our Exchange environment and within Office365.

    I am looking for a powershell script to do the following.

    List all mailboxes for a specific domain, information to include mailbox size, email address and if archiving has been enabled.

    Next for shared mailboxes, need to list them and who has access to them

    Both scripts would need exporting to CSV.

    If anyone could help it would be greatly appreciated, as i have very limited powershell skils unfortunately.

    Jit

    Friday, May 17, 2019 11:40 AM

Answers

  • Hi Jit,

    Here are two command which may be useful to you:

    Script 1: Export information for mailboxes which email address is "@domain.com"

    $Mailboxes = Get-Mailbox | where{$_.PrimarySmtpAddress -like "*@domain.com"}
    $Data = @()
    
    ForEach($Mailbox in $Mailboxes){
        $temp = Get-Mailbox $Mailbox | Select PrimarySmtpAddress,ArchiveDatabase,@{Expression={};Label="TotalItemSize";}
        $temp.TotalItemSize = (Get-MailboxStatistics $Mailbox).TotalItemSize
        $Data+=$temp
    }
    $Data | Export-Csv c:/temp/MailboxesInformation.csv -NoTypeInformation 

    Script 2: Export Full Access permission for shared mailbox:

    $Mailboxes = Get-Mailbox | where{$_.RecipientTypeDetails -eq "SharedMailbox"}
    
    ForEach($Mailbox in $Mailboxes){    
        $temp = Get-MailboxPermission $Mailbox | Where{$_.IsInherited -eq $False -and $_.AccessRights -eq "FullAccess"} | Select User
        $temp | Export-Csv c:/temp/$Mailbox.csv -NoTypeInformation 
    }
    

    By the way, our forum is for questions and feedback related to Exchange server. Usually, we also help users modify  their scripts but don't support for writing scripts directly. If you have a need for scripts, in order to better solve your problem, I suggest you post your need in the script center forum

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Marked as answer by jitla71 Monday, May 20, 2019 6:50 AM
    Monday, May 20, 2019 4:20 AM
    Moderator

All replies

  • Hi Jit,

    Here are two command which may be useful to you:

    Script 1: Export information for mailboxes which email address is "@domain.com"

    $Mailboxes = Get-Mailbox | where{$_.PrimarySmtpAddress -like "*@domain.com"}
    $Data = @()
    
    ForEach($Mailbox in $Mailboxes){
        $temp = Get-Mailbox $Mailbox | Select PrimarySmtpAddress,ArchiveDatabase,@{Expression={};Label="TotalItemSize";}
        $temp.TotalItemSize = (Get-MailboxStatistics $Mailbox).TotalItemSize
        $Data+=$temp
    }
    $Data | Export-Csv c:/temp/MailboxesInformation.csv -NoTypeInformation 

    Script 2: Export Full Access permission for shared mailbox:

    $Mailboxes = Get-Mailbox | where{$_.RecipientTypeDetails -eq "SharedMailbox"}
    
    ForEach($Mailbox in $Mailboxes){    
        $temp = Get-MailboxPermission $Mailbox | Where{$_.IsInherited -eq $False -and $_.AccessRights -eq "FullAccess"} | Select User
        $temp | Export-Csv c:/temp/$Mailbox.csv -NoTypeInformation 
    }
    

    By the way, our forum is for questions and feedback related to Exchange server. Usually, we also help users modify  their scripts but don't support for writing scripts directly. If you have a need for scripts, in order to better solve your problem, I suggest you post your need in the script center forum

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Marked as answer by jitla71 Monday, May 20, 2019 6:50 AM
    Monday, May 20, 2019 4:20 AM
    Moderator
  • Thank you very much Kyle, i will make a note for next time.

    Much appreciated.

    Monday, May 20, 2019 6:50 AM