Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

SQL, (remote) WMI, @WMIQUERY

May
12,846
164
Having enabled remote WMI on my work computer, being connected via a VPN, and having the same credentials on both machines, I can, with an elevated PowerShell, do the likes of
Code:
V:\> Get-WmiObject -Namespace "root\cimv2" -query 'select commandline from Win32_process where ProcessId = 3752' -Impersonation 3 -ComputerName lucky

CommandLine  : d:\tc14\tcc.exe /q
Most ok that command line I got from the web. I know very little about SQL.

On the local computer, I can do the same with @WMI.
Code:
v:\> echo %@wmi[root\cimv2,select CommandLine from Win32_process where ProcessId
= ...]

Does anyone know if there's a syntax for specifying the remote machine with @WMI?
 
Got it! This works.
Code:
v:\> wmiquery \\lucky\root\CIMV2 "SELECT CommandLine FROM Win32_Process WHERE ProcessId = 4048"
"D:\TC16\tcc.exe"
That gives me some hope that it will also work with @WMI, but when I try the obvious (?), I get
Code:
v:\> echo %@wmi[\\lucky\root\CIMV2,"SELECT CommandLine FROM Win32_Process WHERE ProcessId = 4048"]
Error (SYS): Invalid parameter
Rex, should it work with @WMI?
 
Back
Top