This is really nothing more than window dressing as it does nothing more than show this (where more os are added as it iterates over the collection:$begin = {$i=0;$out=}$end = { $out }$process = {$i++;Write-Progress-PercentComplete ($i/$filecount*100) -Activity Showing simple counter-Status Progress:}$files = Get-ChildItemC:Windowssystem32$filecount = $files.count$files |ForEach-Object -Begin $begin -Process $process -end $end
Showing simple counter
Progress:
[ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ]
In reality, I used this to indicate how long a file copy was running which looked like this:Also, a nice trick I try to use whenever I can is the first line. Gather two pieces of information in one line:# Collect file info$filecount = ($files = Get-ChildItem -Path $BaseFolder -Recurse).count$begin = {$i=0;$out=}$end = { $out }$process = {$i++;Write-Progress -PercentComplete ($i/$filecount*100) -Activity Copying files -Status Progress:Write-Verbose "$(Write-TimeStamp): Copying $($_.fullname).";Copy-Item -Path $_.fullname -Destination ($_.fullname -replace test,$environment)}
$filecount = ($files = Get-ChildItem -Path $BaseFolder -Recurse).count