1
我在Powershell v。1.0中寫入進度命令時遇到問題。當我在Powershell ISE中包含幾百個文件的測試目錄上運行此腳本時,進度欄將按照公佈的方式工作,並遞歸顯示其中所有文件的名稱。當我在用戶主目錄的公司域上運行它時,進度條根本不會移動,$ files.name只顯示文件夾內的頂級目錄名稱,例如「桌面」,「AppData」等。爲什麼這可能是這種情況?預先感謝任何幫助!PowerShell寫入進度條無法在大文件上工作
$path = "\\company\shares\campus\HomeDir\username"
$dest = "R:\Terminated"
$counter = 0
$files = gci $path -recurse
Foreach($file in $files)
{
Copy-Item $path $dest -recurse -force
Write-Progress -Activity "Backing Up Terminated User HomeDir:" -status $file.name -PercentComplete ($counter/$files.count*100)
$counter++
}
If ($Counter = $files.Count)
{[System.Windows.Forms.MessageBox]::Show("Backup Complete.")}
Else
{[System.Windows.Forms.MessageBox]::Show("File Backup Did Not Finish.")}
它的工作就像魅力特雷弗!謝謝! – user3311261
@ user3311261:不客氣!請按照您認爲合適的方式標記答案:) –