troubleshooting Question

PowerShell Exchange: Get specific MailboxFolder permission

Avatar of SingAbout Martin
SingAbout Martin asked on
PowershellExchangeWindows Server 2008
4 Comments2 Solutions302 ViewsLast Modified:
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?
Dinesh Babu
Messaging Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros