We help IT Professionals succeed at work.
Get Started

PowerShell Exchange: Get specific MailboxFolder permission

301 Views
Last Modified: 2017-03-30
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?
Comment
Watch Question
Messaging Engineer
Commented:
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE