简体   繁体   English

在远程计算机文件系统上执行Powershell脚本

[英]Executing a powershell script on a remote computer file system

There is a powershell script located on the C:\\ . C:\\上有一个powershell脚本。 The script executes a .msu file. 该脚本执行一个.msu文件。

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. Invoke-Command -ComputerName [name] -FilePath C:\\file.txt不起作用,因为它在系统上本地检查要传递的文件以执行。

I want a powershell script that executes another remote powershell script remotely. 我想要一个Powershell脚本,该脚本可以远程执行另一个远程Powershell脚本。

If you use powershell 5 on both sides you could copy the file via: $TargetSession = New-PSSession -ComputerName server 如果在两侧都使用Powershell 5,则可以通过以下方式复制文件:$ TargetSession = New-PSSession -ComputerName服务器

Copy-Item -ToSession $TargetSession -Path "c:\\local\\" -Destination "C:\\remote\\" -Recurse 复制项-ToSession $ TargetSession-路径“ c:\\ local \\”-目标“ C:\\ remote \\”-递归

You could also use copy to admin share c$ 您也可以使用复制来管理共享c $

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"')

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

相关问题 如何使用PowerShell脚本在远程计算机上运行另一个PowerShell脚本 - How to use a PowerShell script to run another PowerShell Script on a Remote Computer 在远程计算机上执行批处理文件的Powershell脚本不执行命令,而是打印命令 - Powershell script which is executing batch file on remote machine is not executing the commands but printing them 使用PowerShell在远程计算机上启动.exe文件 - Starting a .exe file on a remote computer using powershell 使用Java在远程系统上执行批处理文件 - Executing batch file on remote system using Java 将计算机主机名、操作系统以及是否启用 Bitlocker 导出为 CSV 的 PowerShell 脚本 - PowerShell script that exports to CSV the computer Hostname, operating system and if Bitlocker is enabled or not 在 Terraform 中的远程 Windows EC2 实例上执行 Powershell 脚本 - Executing Powershell script on remote Windows EC2 instance in Terraform Powershell确定远程计算机操作系统 - Powershell determine the remote computer OS 操作远程计算机上的文件 - OPening a file on a remote computer 使用带有 GCDS 参数的 PowerShell 脚本执行 EXE 文件 - Executing an EXE file using a PowerShell script with arguments for GCDS 使用PowerShell脚本跟踪多个远程服务器上的日志文件 - PowerShell script to tail log file on multiple remote servers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM