I recently received a new workstation, windows 8.1 at work and am trying to get some Exchange powershell scripts to run on it that I wrote on my Windows 7 box.
Here's an example of the problem:
In Exchange Management Shell I attempt:
get-mailbox -organizationalunit sales -resultsize unlimited | Where-Object {$_.LitigationHoldEnabled -eq $true} | Get-MailboxFolderStatistics
If I run that same command in a Powershell window after running:
Add-PSSnapin Microsoft.Exchange.Management.Powershell.E2010
I get:
WARNING: An unexpected error has occurred and a Watson dump is being generated: Operation is not valid due to the current state of the object.
Get-MailboxFolderStatistics : Operation is not valid due to the current state of the object.
At line:1 char:115
+ ... d -eq $true} | Get-MailboxFolderStatistics
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-MailboxFolderStatistics], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Exchange.Management.Tasks.GetMailboxFolderStatistics
Any ideas?