使用Copy-Item Powershell时显示进度

时间:2014-09-24 20:51:59

标签: powershell

我有一个我在powershell中编写的脚本,它根据服务器上的版本检查本地计算机上的程序版本。如果有新版本,则通过从服务器复制文件来更新本地计算机。该脚本工作正常,但复制文件大约需要一分钟,我想显示某种进度条。

Add-Type –AssemblyName System.Windows.Forms

$source =  "G:\ERP\ERP.ade"
$destination = "C:\ERP\ERP.ade"

$sourceVersionFile = "G:\ERP\Version.txt"
$destinationVersionFile = "C:\ERP\Version.txt"

$sourceVersion = get-content $sourceVersionFile
$destinationVersion = get-content $destinationVersionFile

$sourceVersion -as [double]
$destinationVersion-as [double]

if ($sourceVersion-gt $destinationVersion){
$OUTPUT= [System.Windows.Forms.MessageBox]::Show("There is a new version of the ERP Available. Download it now?" , "Update ERP?" , 4)
if ($OUTPUT -eq "YES" ) 
{
Copy-Item $source $destination
Copy-Item $sourceVersionFile $destinationVersionFile
} 
else 
{
[System.Windows.Forms.MessageBox]::Show("The ERP was not updated." , "ERP not Updated.")
} 
}

0 个答案:

没有答案
相关问题