简体   繁体   English

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

[英]powershell execute start-process on remote machine

IDE: PowerShell ISE IDE:PowerShell ISE

I have a script which installs the chrome to a remote machine我有一个将 chrome 安装到远程机器的脚本

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

and I am executing the above script using :我正在使用以下脚本执行上述脚本:

Invoke-Command -ComputerName MySystem18 -FilePath D:\Test01.ps1 -ArgumentList Process  

The above script is working on local system (MySystem03) and remote machine (MySystem18).上述脚本适用于本地系统 (MySystem03) 和远程机器 (MySystem18)。

But when I am executing this in MySystem18 it is not showing up the acknowledgement or cursor after the installation of chrome, even after successful installation of chrome on MySystem18.但是,当我在 MySystem18 中执行此操作时,即使在 MySystem18 上成功安装了 chrome 后,它也不会显示确认或光标。

Can you tell me how to fix it.你能告诉我如何解决它。

D:\\Chrome\\Chrome.exe is a path on your remote computer ? D:\\Chrome\\Chrome.exe 是远程计算机上的路径? If not, try to share a dir with Chrome.exe named yourdirshared on your mysystem03 and replace by \\\\mysystem03\\yourdirshared\\Chrome.exe into your ps1如果没有,请尝试在 mysystem03 上与 Chrome.exe 共享一个名为 yourdirshared 的目录,然后将 \\\\mysystem03\\yourdirshared\\Chrome.exe 替换为您的 ps1

if always doesnt work, you can try to remove -wait my be...如果总是不起作用,您可以尝试删除-等待我的...

if always doesnt work, are you try to specify credentil parameter?如果总是不起作用,您是否尝试指定 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