powershell在远程机器上执行启动过程

时间:2016-11-14 09:03:09

标签: powershell powershell-v4.0

IDE:PowerShell ISE

我有一个将chrome安装到远程计算机的脚本

#Script : Test01.ps1
Start-Process D:\Chrome\Chrome.exe -wait -verb runas  
write-host "Chrome is installed"

我正在使用:

执行上述脚本
Invoke-Command -ComputerName MySystem18 -FilePath D:\Test01.ps1 -ArgumentList Process  

上述脚本正在本地系统(MySystem03)和远程机器(MySystem18)上运行。

但是当我在MySystem18中执行它时,即使在MySystem18上成功安装了chrome之后,它也没有在安装chrome后显示确认或光标。

你能告诉我如何解决它。

1 个答案:

答案 0 :(得分:0)

D:\ Chrome \ Chrome.exe是远程计算机上的路径?如果没有,请尝试与mysystem03上名为yourdirshared的Chrome.exe共享目录,并将\\ mysystem03 \ yourdirshared \ Chrome.exe替换为ps1

如果总是不起作用,你可以尝试删除-wait my be ...

如果总是不起作用,您是否尝试指定credentil参数?

$Username = 'username'
$Password = 'yourpassword
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Invoke-Command -ComputerName "MySystem18" -Credential $Cred -ScriptBlock {Start-Process D:\Chrome\Chrome.exe -wait -verb runas; write-host "Chrome is installed" }