make equivilent wql query for the following powershell script

195 views Asked by At

I'm trying to get equivalent query to the following script

$domain='Domain' $group='Group' $t="SELECT PartComponent FROM Win32_GroupUser WHERE GroupComponent="Win32_Group.Domain='xx',Name='xxx'""

`

$query=$t -f $domain,$group Get-WmiObject -Query $query -computer $domain | %{wmi}| select Description, Disabled, Domain, FullName, Lockout, Name, SID

your suggestion are appreciated

1

There are 1 answers

1
js2010 On

Something like this works on my computer. Notice the surrounding single quotes. I'm piping to where-object rather than dealing with quoting a -filter to get-wmiobject. I was hoping domain and name were other properties by themselves, but I didn't see them. GroupComponent looks like a wmi object path.

get-wmiobject Win32_GroupUser | 
where groupcomponent -eq '\\DESKTOP-JQ7B7RP\root\cimv2:Win32_Group.Domain="DESKTOP-KQ7B7RQ",Name="Administrators"' |
select partcomponent