Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Looping a Foreach-Object

$
0
0
How do I get this script to loop through the ForEach-Object loop five times before it runs the line to copy the file? ($EXMBX has five entries) $Date=Get-Date -Format yyyyMMMMdd $file = New-Item -type file "$date-EXMBX_Mailboxes.test.txt" $EXMBX=Get-MailBoxSerevr $EXMBX | ForEach-Object{ Get-MailboxStatistics -server $_.Name | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(KB)";expression={$_.TotalItemSize.Value.ToKB()}},ItemCount,Database,ServerName > $file } Copy-Item $file -destination "\\itdata\docs\Domain Services Documentation\Messaging\Exchange2010\Mailbox Monthly Export" Thanks Jonathan

Viewing all articles
Browse latest Browse all 6937

Trending Articles