Question

I recently notice that when creating powershell scripts that use the Add-WindowsFeature cmdlet from the ServerManager Module on Windows Server 2008 R2, there is an aqua-blue overlay that does not get cleared until the entire script is finished. For example, here is a screenshot of a script that uses the Add-WindowsFeature Web-Server command to install IIS:

Add-WindowsFeature Web-Server overlay

The Collecting data... Start Installation... overlay stays on top of the console history and does not disappear until after the entire script is finished. Is there any way to get the console to re-paint itself or to disable the overlay?

Was it helpful?

Solution

This is just result of Write-Progress called internally by server manager cmdlets. If you want to make it silent - just change your $ProgressPreference to 'SilentlyContinue'.

You can emulate this by using Write-Progress your self:

for ($i = 0; $i -lt 100; $i++) { 
    Write-Progress -Activity "Counting: $i" -Status "$i" -PercentComplete $i
    sleep 1 
}

HTH Bartek

OTHER TIPS

I found an interesting way to fix this. In using write-progress you can simply implement a secondary loop that does absolutely nothing but add a -completed switch at the end.

for ($i = 1; $i -le 100; $i++ )
{write-progress -activity "Search in Progress" -status "$i% Complete:" -percentcomplete $i;}

The above code would of course be your functional loop that is displaying progress and actually doing something.

for ($i = 1; $i -le 100; $i++ ) {
write-progress -activity "Finishing" -status "$i% Complete:" -percentcomplete $i -Completed;}

Running this exact snippet that does nothing and because you use the -completed switch makes the progress dialog overlay disappear. Not exactly a neat solution, but a solution for my needs nonetheless.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top