Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Problem sending powershell foreach output to text file

$
0
0

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


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>