输出到控制台,但与 PowerShell 中的最后一个输出在同一行

Pro*_*m.X 1 powershell

我正在编写一个脚本来备份我们的 SVN 存储库,基于http://www.codeproject.com/KB/powershell/SVNBackupPower.aspx。它工作得很好,但是当它等待 ZIP 完成时,我希望它在每次迭代时发出一个点而不是一个新行。所以,

Waiting for ZIP ...................
Run Code Online (Sandbox Code Playgroud)

与

Waiting for ZIP
Waiting for ZIP
Waiting for ZIP
Waiting for ZIP
(you get the picture)
Run Code Online (Sandbox Code Playgroud)

我猜当时 BASIC 中的等价物是:

PRINT ".";
Run Code Online (Sandbox Code Playgroud)

但是 PowerShell 等价物是什么?

sys*_*138 7

很简单...

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

关键是-nonewline。您甚至可以通过-foregroundcolor.