仅依赖 WMI 和 PowerShell 的 Windows 远程执行工具。
远程执行控制台命令并捕获 stdout/stderr 流,无需依赖 PowerShell Remoting、WinRM 或 PsExec。
下面的示例展示了 WmiExec 如何从管道接受命令字符串作为值。
PS C:\ "Get-ChildItem C:\" | .\WmiExec.ps1 -ComputerName "server1"
Running the following command on: server1...
Get-ChildItem C:\
PID: 5580 - Waiting for remote command to finish...
PID: 5580 - Waiting for remote command to finish...
Result...
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 28.06.2018 15:16 PerfLogs
d-r--- 09.09.2019 15:19 Program Files
d-r--- 07.10.2019 08:36 Program Files (x86)
d-r--- 10.10.2019 10:51 Users
d----- 10.10.2019 16:00 Windows
下面的示例展示了返回的对象类型。
PS C:\ $result = .\WmiExec.ps1 -ComputerName "server1" -Command "Get-ChildItem C:\"
Running the following command on: server1...
Get-ChildItem C:\
PID: 5580 - Waiting for remote command to finish...
PID: 5580 - Waiting for remote command to finish...
Result...
PS C:\ $result.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
Twitter https://twitter.com/OneScripter
使用 System Frontier,为你的 PowerShell 脚本创建利用 RBAC 的 Web GUI,做更多酷炫的事情。 https://systemfrontier.com/powershell