locked
Get-MailboxFolderPermission of multiple Calendars from the Pipeline using CSV Import RRS feed

  • Question

  • Hi All,

    We have an Exchange 2010 SP2 environment...

    I was trying to figure out how query multiple Resource Room Calendars for their Access Rights.

    I first got a list of the Resource Rooms I wanted based off their CustomAttribute1:

    C:\>Get-Mailbox -ResultSize unlimited | Where-Object { $_.CustomAttribute1 -eq "Specific Resource" } | select-object Alias | export-csv "C:\ResourceRooms.csv"

    The resultant csv file's alias contents were encapsulated in quotes...

    I then tried variations of the following and I don't get an error or anything:

    C:\>Import-Csv "c:\ResourceRooms.csv" | ForEach-Object { Get-MailboxFolderPermission -identity $($_ +':\Calendar') } | ft User,AccessRights

    I tried this based off of many searches...one of them looked promising, but I'm posting here in the hopes someone sees what I'm doing incorrectly:

    http://powershell.com/cs/forums/p/8035/13115.aspx

    Any ideas - Thank you for your time!

    Mr Mister

    Tuesday, February 7, 2012 8:14 PM

Answers

  • Hi Mr Mister,

    Change your command “C:\>Import-Csv "c:\ResourceRooms.csv" | ForEach-Object { Get-MailboxFolderPermission -identity $($_ +':\Calendar') } | ft User,AccessRights” to this:

    Import-Csv "c:\ResourceRooms.csv" | ForEach-Object {

    $user=$_.Alias

    $path=$user+”:\Calendar”

    Get-MailboxFolderPermission –identity $path |ft User, AccessRights}

    Thanks,

    Evan
     


    Evan Liu

    TechNet Community Support



    Thursday, February 9, 2012 10:13 AM
    Moderator

All replies

  • Hi Mr Mister,

    Change your command “C:\>Import-Csv "c:\ResourceRooms.csv" | ForEach-Object { Get-MailboxFolderPermission -identity $($_ +':\Calendar') } | ft User,AccessRights” to this:

    Import-Csv "c:\ResourceRooms.csv" | ForEach-Object {

    $user=$_.Alias

    $path=$user+”:\Calendar”

    Get-MailboxFolderPermission –identity $path |ft User, AccessRights}

    Thanks,

    Evan
     


    Evan Liu

    TechNet Community Support



    Thursday, February 9, 2012 10:13 AM
    Moderator
  • This is very helpful.  I'm trying to redirect the output to a file.  In the last line with the Get-MailboxFolderPermission I've modified it to be this:

    Get-MailboxFolderPermission -identity $path |ft $path,User,AccessRights > C:\Users\me\Desktop\CalendarPermissions\IPCalPermsOutput.txt }

    Only the last entry in the imported csv file is displaying, however when I run the command without the redirect > it shows everything the way I want it shown:

    user:\Calendar                   User                                    AccessRights
    ---------------------                   ----                                    ------------
                                            Default                                 {AvailabilityOnly}
                                            User                                     {Reviewer}
                                            User                                     {Editor}
                                            User                                     {Editor}
                                            User                                     {Reviewer}
                                            EXCH-MRAdmins                   {Editor}
                                            EXCH-MR-CalendarContact     {Editor}
                                            View All IP Calendars             {Reviewer}


    • Edited by Versant IT Tuesday, July 10, 2012 8:34 PM names changed
    Tuesday, July 10, 2012 8:33 PM
  • Hi,

    Not sure if you ever came right with your request. I know its dated back in 2012.... I needed to so something similar and landed on this. Anyways.... using some of your code I managed to construct this and it seems to work very well:

    Run the Command like this:

    .\Export-CalPerms.ps1 -ExchangeServer SERVER1-ExportPath .\CalPerms-SERVER1.csv

    #### Save this to Powershell Export-CalPerms.ps1

    param(
        [Parameter(Mandatory = $true)]
        [string] $ExchangeServer = “”,
        [Parameter(Mandatory = $true)]
        [string] $ExportPath = “”
        )

    $Mailboxes = Get-Mailbox -Server $ExchangeServer -ResultSize Unlimited | Select Alias
    $AllCalPerms = @()
    $CalPermAttribs = "" | Select Mailbox,Identity,User,AccessRights

    $Mailboxes | ForEach-Object {
        $User=$_.Alias
        $Path=$User+”:\Calendar”
        foreach ($CalPermAccessRights in Get-MailboxFolderPermission –identity $Path) {
           $CalPermAttribs.Mailbox = $User
           $CalPermAttribs.Identity = $CalPermAccessRights.Identity
           $CalPermAttribs.User = $CalPermAccessRights.User
           $CalPermAttribs.AccessRights = $CalPermAccessRights.AccessRights
           $AllCalPerms += $CalPermAttribs | Select Mailbox,Identity,User,@{l='AccessRights';e={$_.AccessRights}}
        }
    }

     $AllCalPerms | Export-Csv -Path $ExportPath -NoTypeInformation
     
     Write-Host Exported the result for $ExchangeServer

    #### EOF


    Wednesday, April 30, 2014 7:09 AM
  • Hi Jannie van der Walt,

    That's a handy script...thank you very much for taking the time to share it!

    Kindest Regards,

    Mr Mister

    Thursday, May 1, 2014 9:07 PM
  • Been BANGING my head on this one for a few days. Thanks so much for sharing man!
    Wednesday, October 28, 2015 5:54 PM