我正在编写一个脚本来备份我们的SVN存储库,基于http://www.codeproject.com/KB/powershell/SVNBackupPower.aspx 。 它工作得很好,但是当等待ZIP完成时,我希望它在每次迭代中发出一个点而不是一个新行。 所以,
Waiting for ZIP ...................
而不是
Waiting for ZIP Waiting for ZIP Waiting for ZIP Waiting for ZIP (you get the picture)
我想在BASIC中相当于从今天起将是:
PRINT ".";
但是什么是PowerShell等价物?
很简单…
write-host "Waiting for zip" -nonewline while ($inloop -eq true) { write-host "." -nonewline $inloop=Get-LoopStatus($Thingy) } write-host "."
关键是-nonewline 。 你甚至可以通过-foregroundcolor使这些额外的位不同的颜色。
您也可以使用write-progress cmdlet来显示进度栏。