Results file for Exchange Powershell script
I don't think you need the foreach-object. Export-mailbox takes pipeline input. As for your script, this probably doable, but I don't have a 2007 server handy. If you export a single mailbox, does the desired output appear on the screen? If so, you can send the results of each job to an array (variable) and then export that variable to a csv once it's all done. Here is an example where I'm doing something else, but I use this approach of collecting results and then sending it to a variable called $masterlist. If it works, just change the last line to $masterlist | export-csv c:\file.csv http://mikecrowley.wordpress.com/2012/04/17/combining-powershell-cmdlet-results/ Mike Crowley | MVP My Blog -- Planet Technologies
April 27th, 2012 6:51pm

Hi I am using the following script to delete content from a mailbox: Get-Mailbox -Identity User1 | Export-Mailbox -SubjectKeywords Deletethis -StartDate 12/12/2011" -DeleteContent | out-file c:\results.log I actually have several mailboxes that I need to do this on, so am going to use this: Get-content c:\userlist.txt | ForEach-Object {Export-Mailbox -Identity $_ -SubjectKeywords Deletethis -StartDate 12/12/2011" -DeleteContent} What I'd like to be able to have is a result file at the end of the script that lists the mailboxes that the script worked on and how many messages were deleted. Does anyone know how this is possible?
Free Windows Admin Tool Kit Click here and download it now
April 27th, 2012 8:28pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics