PowerShell – Overwriting line written with Write-Host

You cannot overwrite a line in a Powershell window. What you can do is blank the window with cls(Clear-Host):

# loop code
cls
Write-Host "`rWriting $outputFileName ($i/$fileCount)... $perc%"
# end loop

But what you should really be using is Write-Progress, a cmdlet built specifically for this purpose:

# loop code
Write-Progress -Activity "Writing $outputFileName" -PercentComplete $perc
# end loop

More on Write-Progress here: http://technet.microsoft.com/en-us/library/hh849902.aspx

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)