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?
ASKER