Link to home
Start Free TrialLog in
Avatar of SingAbout Martin
SingAbout Martin

asked on

PowerShell Exchange: Get specific MailboxFolder permission

What I'm trying to do is get an export of all Mailboxes within a specific OU of which the user "Default" has the AccessRights of "Owner". I'm running Exchange 2010 and have the ability to use PowerShell 2.0 (from Windows Server 2008 R2) or PowerShell 4.0 (from Windows Server 2012 R2). I'm running Exchange 2010.

$AllMailbox = Get-Mailbox -OrganizationalUnit "DN of OU" -ResultSize Unlimited ForEach ($Mailbox) in ($AllMailbox) {Get-MailboxFolderPermission $Mailbox | Where-Object {$_.User -Match "Default" -AND $_.AccessRights -Match "Owner"} | Select-Object Identity,AccessRights,@{Name="Name"; Expression={$Mailbox.Name}}} | Export-CSV -Path C:\temp\export.csv

However I'm getting the following error. A valid OrganizationalUnit DN is given.

ForEach-Object : Cannot bind parameter 'RemainingScripts'. Cannot convert the "in" value of type "System.String" to type "System.Management.Automati on.ScriptBlock". At line:1 char:134 + $AllMailbox = Get-Mailbox -OrganizationalUnit "OU=X,OU=X ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [ForEach-Object], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ForEachObjectCommand

Any suggestions?
SOLUTION
Avatar of Alex
Alex
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SingAbout Martin
SingAbout Martin

ASKER

No Alex, the permissions that you get from MailboxPermission (Full Access etc.) is different from MailboxFolderPermission (Default, Anonymous, etc.) which is on the Folder level and not the entire mailbox.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hence no response from author I am closing this question.
Thanks