Powershell progress dialogs

Posted by Norgean on Geeks with Blogs See other posts from Geeks with Blogs or by Norgean
Published on Wed, 11 Apr 2012 11:21:55 GMT Indexed on 2012/04/11 11:31 UTC
Read the original article Hit count: 191

Filed under:

Creating nested progress dialogs in Powershell is easy.

Let the code speak for itself:

for ($i = 1; $i -le 2; $i++)

{

    Write-Progress -ID 1 -Activity "Outer loop" -Status "Tick $i" -percentComplete ($i / 2*100)

    for ($j = 1; $j -le 3; $j++)

    {

        Write-Progress -ID 2 -Activity "Mid loop" -Status "Tick $j" -percentComplete ($j / 3*100)

        for ($k = 1; $k -le 3; $k++)

        {

            Write-Progress -ID 3 -Activity "Inner loop" -Status "Tick $k" -percentComplete ($k / 3*100)

            Sleep(1)

        }

    }

}

I.e. some text that explains what we're doing (Activity and Status), and ID numbers.

Easy.

ProgressDialog

© Geeks with Blogs or respective owner