0
votes

With PowerShell, I want to make an export of all the mailboxes in an Exchange environment of users in a specific OU where the level of AccessRights of the user "Default" on the folder level does not equal "None". For this I am using the following command:

$AllMailbox = Get-Mailbox -OrganizationalUnit "DNofOU" -ResultSize Unlimited 
$ResultData = foreach ($Mailbox in $AllMailbox) 
    {
        Get-MailboxFolderPermission $Mailbox | Where-Object {$_.User -Match "Default" -AND $_.AccessRights -NotMatch "None"} | Select-Object Identity,AccessRights,@{Name="Name"; Expression={$Mailbox.Name}}
    }  
$ResultData | Export-CSV -Path C:\temp\MailboxFolderPermissions.csv

However, when running this command I get the following error:

Cannot process argument transformation on parameter 'Identity'. Cannot convert the "DisplayNameOfMailbox" value of type "Deserialized.Microsoft.Exc hange.Data.Directory.Management.Mailbox" to type "Microsoft.Exchange.Configuration.Tasks.MailboxFolderIdParameter". + CategoryInfo : InvalidData: (:) [Get-MailboxFolderPermission], ParameterBindin...mationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-MailboxFolderPermission + PSComputerName : FQDNofExchangeServer

The environment is based on Exchange 2010 on a Windows Server 2008 R2 server with PowerShell version 2.0. It is also possible to execute this from a Windows Server 2012 R2 server with PowerShell version 4.0 when remote connecting to the Exchange server.

1

1 Answers

0
votes

For me, it worked better to use the full Canonical name of the object. Like so:

$mailboxArray = Get-Mailbox -OrganizationalUnit "example.com/Accounts" -ResultSize Unlimited

I Wasn't sure if this for have found the answer or not yet, but wanted to provide my input on how you could possibly get all the mailboxes in an organizational Unit.