
Ejecuta comandos de Windows de forma remota y captura la salida usando solo WMI y PowerShell (sin remoting).
Herramientas de ejecución remota para Windows que dependen únicamente de WMI y PowerShell.
Ejecuta comandos de consola de forma remota y captura los flujos stdout/stderr sin depender de PowerShell Remoting, WinRM ni PsExec.
Entrada de blog y vídeo sobre esta técnica.
El siguiente ejemplo muestra cómo WmiExec puede aceptar la cadena de comando como valor desde la canalización.
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
El siguiente ejemplo muestra el tipo de objeto que se devuelve.
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
Haz cosas aún más interesantes, como crear interfaces web (GUI) para tus scripts de PowerShell que aprovechen RBAC, usando System Frontier. https://systemfrontier.com/powershell