在远程计算机文件系统上执行 powershell 脚本 [英] Executing a powershell script on a remote computer file system

查看:36
本文介绍了在远程计算机文件系统上执行 powershell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C:\ 上有一个 powershell 脚本.该脚本执行一个 .msu 文件.

There is a powershell script located on the C:\. The script executes a .msu file.

Invoke-Command -ComputerName [name] -FilePath C:\file.txt 不起作用,因为它会在您的系统本地检查要传递的文件以执行.

Invoke-Command -ComputerName [name] -FilePath C:\file.txt doesn't work because it checks locally on your system for the file to pass over to execute.

我想要一个远程执行另一个远程 powershell 脚本的 powershell 脚本.

I want a powershell script that executes another remote powershell script remotely.

推荐答案

如果你试试这个方法呢?

And if you try this method?

在本地机器上运行这个命令:

Run this command on your local machine :

$computer = "COMP1"    
([WMICLASS]"\\$computer\ROOT\CIMV2:Win32_Process").Create('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -File "script.ps1"')

这篇关于在远程计算机文件系统上执行 powershell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆