

You can get the same result using Write-Progress, which is frankly a little easier to use. Measure-Object -Property Length -Sum = $untĪt the end of the script I clean up after myself and close the form. $stats = Get-ChildItem -path $folder -Recurse -File | $label1.text="Measuring size: $($folder.Name)" $top = Get-ChildItem -Path $path -DirectoryĪs I've been doing all along, I'll use ForEach to process each item, calculate my percentage complete and use that value for the progress bar. $label1.text="Preparing to analyze $path" Now I can show the form and start the main part of my PowerShell script. Using the values for the label and some trial and error, I specify where the progress bar should start on the form.įinally, like the other controls, the progress bar needs to be added to the form. $progressBar1.Size = $System_Drawing_Size

Next, I need to create a drawing object and use that to give the progress bar its size. Setting the style to "Continuous" will give us a nice looking and smooth progress bar. Now to create and add the ProgressBar control. One change I made from my earlier example was to adjust the height of the label control. #adjusted height to accommodate progress bar
