![](/img/trans.png)
[英]How to use a PowerShell script to run another PowerShell Script on a Remote Computer
[英]Executing a powershell script on a remote computer file system
在C:\\
上有一个powershell脚本。 该脚本执行一个.msu文件。
Invoke-Command -ComputerName [name] -FilePath C:\\file.txt
不起作用,因为它在系统上本地检查要传递的文件以执行。
我想要一个Powershell脚本,该脚本可以远程执行另一个远程Powershell脚本。
如果在两侧都使用Powershell 5,则可以通过以下方式复制文件:$ TargetSession = New-PSSession -ComputerName服务器
复制项-ToSession $ TargetSession-路径“ c:\\ local \\”-目标“ C:\\ remote \\”-递归
您也可以使用复制来管理共享c $
如果您尝试这种方法?
在本地计算机上运行以下命令:
$computer = "COMP1"
([WMICLASS]"\\$computer\ROOT\CIMV2:Win32_Process").Create('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -File "script.ps1"')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.