Mailbox Permission Question


  • I am not a pro at PS, but I need a list of permissions on some Exchange 2007 mailboxes that are permissions that are NOT inherited on a specific set of mailboxes.  I have a text file with SAM account names that I want to use to pull into a script.  I also want the script to output the data to a CSV file, in the following format:

    Display NameUser Access Rights


    Joe User LoginName Full Access, Read Access etc

    So far, I have this.  But the Access Rights field returns the following on the output: Microsoft.Exchange.Management.RecipientTasks.MailboxRights[].  Any help appreciated!


    [Array] $mbpermCollection = @() 
    $InputFile = @(Get-Content C:\Scripts\users.txt)

    # Get All Mailboxes Contained on Input Text File 
    $InputFile | Get-Mailbox | Select DistinguishedName, Displayname | ForEach {

    # Get Access Rights for User Mailbox
    $MBPerms = Get-MailboxPermission $_.DistinguishedName | where { ($_.IsInherited -eq $false)} | Select Identity, User, AccessRights

    $mboutput = "" | Select "Display Name", User, "Access Rights" 
    $mboutput."Display Name" = $_.DisplayName
       $mboutput.User = $mbperms.User
    $mboutput."Access Rights" = $mbperms.AccessRights

    $mbpermCollection += $mboutput

    $mbpermCollection | Export-Csv C:\Scripts\"MailboxPerms $(Get-Date -f 'yyyyMMdd').csv" -NoType

    Wednesday, November 21, 2012 8:03 PM


All replies

  • Sorry the post did not show the desired output correctly.  I basically am looking for a CSV file with three columns each named: Display Name, User, and Access Rights.



    Wednesday, November 21, 2012 8:06 PM
  • Tuesday, December 18, 2012 10:45 PM
  • Hi ebunky,

    I think it's because export-CSV doesn't know what to do with the AccessRights property. Looking at it in my environment, it looks like it's not actually an array of values, as powershell understands it. It does, however, seem to be able to be typed as a string quite easily

    So change your line:

    $mboutput."Access Rights" = $mbperms.AccessRights


    $mboutput."Access Rights" = [String]($mbperms.AccessRights)

    And it should work. I hope!


    Wednesday, December 19, 2012 12:18 PM