PowerShell-Docs icon indicating copy to clipboard operation
PowerShell-Docs copied to clipboard

Example does not perform as described .

Open manuelh2410 opened this issue 5 years ago • 1 comments

for the following example detailed in : https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-progress?view=powershell-7.1#syntax does not perform as described .

according to the documentation , the code block should generate a progress bar . "This command displays the progress of a For loop that counts from 1 to 100."

for ($i = 1; $i -le 100; $i++ )
{
    Write-Progress -Activity "Search in Progress" -Status "$i% Complete:" -PercentComplete $i;
}

It seems that the progress bar is only displayed when the "Set-PSDebug -trace 1" command is executed prior to running the code block . It also seems to work with other trace levels , for example -trace 2

Set-PSDebug -trace 1

for ($i = 1; $i -le 100; $i++ )
{
    Write-Progress -Activity "Search in Progress" -Status "$i% Complete:" -PercentComplete $i;
}

I tested this in powershellISE and powershell 7.1


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

manuelh2410 avatar Apr 29 '21 21:04 manuelh2410

The example works but it runs so fast you don't see the progress bar or you just see it flash.

sdwheeler avatar Apr 29 '21 23:04 sdwheeler