
Execute comandos do Windows remotamente e capture a saída usando apenas WMI e PowerShell (sem remoting).
Ferramentas de execução remota para Windows que dependem apenas de WMI e PowerShell.
Execute comandos de console remotamente e capture os fluxos stdout/stderr sem depender de PowerShell Remoting, WinRM ou PsExec.
Post de blog e vídeo sobre esta técnica.
O exemplo abaixo mostra como o WmiExec pode aceitar a string de comando como um valor do pipeline.
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
O exemplo abaixo mostra o tipo de objeto que é retornado.
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
Faça coisas ainda mais interessantes, como criar GUIs web para seus scripts PowerShell que aproveitam RBAC, usando o System Frontier. https://systemfrontier.com/powershell