2

I'm writing a script to backup our SVN repositories, based on http://www.codeproject.com/KB/powershell/SVNBackupPower.aspx. It works sweet, but when it's waiting for the ZIP to complete, I'd like it to issue a dot instead of a new line each iteration. So,

Waiting for ZIP ...................

as opposed to

Waiting for ZIP
Waiting for ZIP
Waiting for ZIP
Waiting for ZIP
(you get the picture)

I guess the equivalent in BASIC from back in the day would be:

PRINT ".";

But what's the PowerShell equivalent?

2 Answers 2

8

Pretty simple...

write-host "Waiting for zip" -nonewline
while ($inloop -eq true) {
    write-host "." -nonewline
    $inloop=Get-LoopStatus($Thingy)
}
write-host "."

The key is -nonewline. You can even make those additional bits different colors via -foregroundcolor.

2
  • Perfect. Thank you. I knew it would be, unfortunately, a little more difficult to search for. Have been trawling through all sorts of complicated formatting options.
    – Program.X
    Dec 16, 2011 at 15:42
  • as already mentioned here : Write-Host writes text to the PowerShell host display, not the pipeline., so Write-Host is almost always the wrong command Apr 15, 2018 at 19:12
3

You could also use the write-progress cmdlet to visualize a progress bar.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .