Example does not perform as described .
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.
- ID: 36e23e32-2baa-1934-870a-14c4e78ab67c
- Version Independent ID: 7574a215-cb3f-fb75-199d-362ae1edd163
- Content: Set-PSDebug (Microsoft.PowerShell.Core) - PowerShell
- Content Source: reference/7.1/Microsoft.PowerShell.Core/Set-PSDebug.md
- Product: powershell
- Technology: powershell-cmdlets
- GitHub Login: @SteveL-MSFT
- Microsoft Alias: slee
The example works but it runs so fast you don't see the progress bar or you just see it flash.