Link to home
Start Free TrialLog in
Avatar of fireguy1125
fireguy1125

asked on

Exchange 2010 List Folders in Mailbox Powershell

I need to run a query on all mailboxes in my Exchange 2010 environment.  I found one that accomplishes what I need, however it is throwing an error when I run it.

Get-Mailbox -ResultSize Unlimited | Select-Object alias | foreach-object {Get-MailboxFolderStatistics -Identity $_.alias | select-object Identity, ItemsInFolder, FolderSize} | Export-csv c:\MBFolderStats.csv -NoTypeInformation

Open in new window


Produces error:

Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
    + CategoryInfo          : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [], PS
    + FullyQualifiedErrorId : RemotePipelineExecutionFailed

Open in new window


I need help re-writing it as apparently the following is the cause:

This error is caused because the Windows PowerShell remoting feature doesn’t
support more than one pipeline running at the same time. To resolve this
issue, store the output of the cmdlet earlier in the pipeline in a variable,
and then pipe the data stored in the variable to the ForEach cmdlet.

Thanks in advance!
Avatar of achaldave
achaldave
Flag of United States of America image

Try
Get-Mailbox -ResultSize Unlimited |  foreach-object {Get-MailboxFolderStatistics -Identity $_.identity | select-object Identity, ItemsInFolder, FolderSize} | Export-csv c:\MBFolderStats.csv -NoTypeInformation

If it doesn't work try,
$Mailboxes = $ Get-Mailbox -ResultSize Unlimited
$Mailboxes  |  foreach-object {Get-MailboxFolderStatistics -Identity $_.identity | select-object Identity, ItemsInFolder, FolderSize} | Export-csv c:\MBFolderStats.csv -NoTypeInformation

http://technet.microsoft.com/en-us/library/dd351136.aspx
Avatar of fireguy1125
fireguy1125

ASKER

Neither of those works:

For the 1st one, I still get the pipeline error

For the 2nd one, I get the following:

[PS] C:\Windows\system32>$Mailboxes = $ Get-Mailbox -ResultSize Unlimited
The term '$' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
included, verify that the path is correct and try again.
At line:1 char:15
+ $Mailboxes = $ <<<<  Get-Mailbox -ResultSize Unlimited
    + CategoryInfo          : ObjectNotFound: ($:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

[PS] C:\Windows\system32>$Mailboxes  |  foreach-object {Get-MailboxFolderStatistics -Identity $_.identity | select-obje
derSize} | Export-csv c:\MBFolderStats.csv -NoTypeInformation
Cannot bind argument to parameter 'Identity' because it is null.
    + CategoryInfo          : InvalidData: (:) [Get-MailboxFolderStatistics], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Get-MailboxFolderStatistics

Open in new window

My mistake, remove $ before get-mailbox command
ASKER CERTIFIED SOLUTION
Avatar of suriyaehnop
suriyaehnop
Flag of Malaysia 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
Solution provided by @suriyaehnop's should work, didn't realized  select-objet is within foreach-object section when I replied. if $_.alias doesn't work, replace it with $_.identity.
Both method in my previous post should look like below
Get-Mailbox -ResultSize Unlimited |  foreach-object {Get-MailboxFolderStatistics -Identity $_.identity} | select-object Identity, ItemsInFolder, FolderSize | Export-csv c:\MBFolderStats.csv -NoTypeInformation

 If it doesn't work try,
 $Mailboxes =  Get-Mailbox -ResultSize Unlimited
 $Mailboxes  |  foreach-object {Get-MailboxFolderStatistics -Identity $_.identity}  | select-object Identity, ItemsInFolder, FolderSize | Export-csv c:\MBFolderStats.csv -NoTypeInformation