Powershell等待过程直到安装完成

时间:2016-02-18 14:14:57

标签: powershell internet-explorer-11 silent-installer

$computers = Read-host "Enter Computer Name"

$computers | where{test-connection $_ -quiet -count 1} | ForEach-Object {

    copy-item C:\SoftwareAndDrivers\IE11 -recurse "\\$_\c$\temp" 

    $newProc=([WMICLASS]"\\$_\root\cimv2:win32_Process").Create("C:\TEMP\IE11\IE11-Windows6.1-x64-en-us.exe /quiet /norestart /update-no")

    If ($newProc.ReturnValue -eq 0) { Write-Host $_ $newProc.ProcessId } else { write-host $_ Process create failed with $newProc.ReturnValue }

    Wait-Process -Id $newProc.ProcessId

    Write-Host "Installed Successfully" -ForegroundColor Green

}

我希望脚本暂停,直到安装IE11,然后继续并显示“已成功安装”。我不能让它暂停。我得到了

  

等待进程:找不到进程标识符为xxxx

的进程

0 个答案:

没有答案