繁体   English   中英

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

[英]powershell execute start-process on remote machine

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 后,它也不会显示确认或光标。

你能告诉我如何解决它。

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

如果总是不起作用,您可以尝试删除-等待我的...

如果总是不起作用,您是否尝试指定 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" } 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM