Hello,
I'm having some trouble outputing a powershell foreach loop to a text file:
foreach($mbx in Get-Mailbox){Get-MailboxFolderStatistics $mbx.identity -FolderScope 'DeletedItems' | select @{n="DisplayName";e={$mbx.displayName}},FolderPath,ItemsInFolder,FolderSize} | Out-File -Append "C:\Exchange_Reports\Deleted_Items.txt"
I created a blank Deleted_Items.txt document at path specified prior to running the script. However, I run into an empty pipe element error just before the Out-File is run. If I remove the pipe preceeding the Out-File command, the output is only displayed on-screen and nothing is appended to the Deleted_Items.txt document.
Can someone help? Am I missing something simple/obvious here?
Thanks!
Sean