Export Mailbox Folder Permissions to CSV RRS feed

  • Question

  • I am working a migration of a couple thousand mailboxes and I need to export mailbox folder permissions so that I can re apply them on the target addresses.  I am having a very difficult time finding and or cobbling together a script to do that.  I want to create csv batch files containing about 200 mailboxes each with primary smtp addresses and run that through a for each loop to produce the necessary results.  It seems like I have to do something like what I have below.  Any advice as to how I can complete this mess?

    $mailboxes = Import-CSV c:\batch1.csv -header PrimarySMTPAddress


    #Loop through each mailbox
    foreach ($mailbox in $mailboxes) {

        $mbfolders = Get-MailboxFolderStatistics -Identity $mailbox.PrimarySMTPAddress


        $mbfolderperms = Get-MailboxFolderPermission -Identity "$($mailbox.PrimarySMTPAddress):\$($mbfolder.Name)" |

    select Mailbox address, mailbox type, Folder name, User with access, Permissions, Permission type |  export-csv 

    Sunday, December 8, 2019 6:35 AM

All replies

  • or you can simply try the below 

    $mailboxes=Get-Mailbox -RecipientTypeDetails SharedMailbox 
    foreach($mailbox in $mailboxes){
    Get-MailboxPermission $ | select Identity,User,AccessRights | Export-Csv C:\temp\$mailbox.csv –NoTypeInformation

    You can change the recipienttypedetails to usermailbox or remoteusermailbox depending on your requirement.

    Import and Export you can use it from your command.

    Kindly mark it as answer if that helped

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered"Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster.]

    Sunday, December 8, 2019 11:39 AM
  • Thanks for the reply. Please take note ---  I am asking for mailbox FOLDER permissions.  I have succesfully run the report for mailbox permissions as that wasnt as intensive as checking each folder in a mailbox for permissions.

    I am looking to use CSV files so I can limit the batches.

    • Edited by jpcapone Sunday, December 8, 2019 4:37 PM
    Sunday, December 8, 2019 1:54 PM
  • ok, so are you looking for a script which can lookup for the permissions on all the folders on a specified mailbox on csv and the result should be back in csv..

    Monday, December 9, 2019 10:31 AM
  • Yes sir.  I am using csv files -

    $mailboxes = import-csv c:\testmail.csv -header primarysmtpaddress 

    Which I would then like to 

    #Loop through each mailbox
    foreach ($mailbox in $mailboxes) {
        #Get Mailbox folder permissions
        #Get the folders for Inbox, Calendar, and Contacts folders of the mailbox
        $mbfolders = Get-MailboxFolderStatistics -Identity $mailbox.PrimarySMTPAddress 

     #Loop through the folders and collect the permissions for each folder
        foreach ($mbfolder in $mbfolders) {

            $mbfolderperms = Get-MailboxFolderPermission -Identity "$($mailbox.PrimarySMTPAddress):\$($mbfolder.Name)" | Where-Object { $_.User -notmatch 'Default' -and $_.User -notmatch 'Anonymous' }

            #Loop through each permission on the folder
            foreach ($mbfolderperm in $mbfolderperms)

    And pipe out the folder path - user with permissions and the permissions to a CSV.

    Monday, December 9, 2019 2:39 PM