We help IT Professionals succeed at work.

Exchange 2010 List Folders in Mailbox Powershell

fireguy1125
fireguy1125 asked
on
5,457 Views
Last Modified: 2014-05-20
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!
Comment
Watch Question

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

Author

Commented:
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
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
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
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.