
Удалённое выполнение команд Windows и захват вывода с использованием только WMI и PowerShell (без remoting).
Инструменты удалённого выполнения для Windows, использующие только WMI и PowerShell.
Выполняйте консольные команды удалённо и захватывайте потоки 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
Делайте ещё больше классных вещей, например создавайте веб-интерфейсы для ваших скриптов PowerShell с поддержкой RBAC, используя System Frontier. https://systemfrontier.com/powershell