Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Translate WMIC query to Powershell

Reply
 
Old 12-06-2007   #1 (permalink)
Chad


 
 

Translate WMIC query to Powershell

I've been using wmic for several years and I'm trying adapt some queries to
Powershell.

I'm having a little trouble with this one which enumerates AD or local
membership:

Here's the wmic query for local and AD respectively
wmic path Win32_GroupUser WHERE
(GroupComponent="Win32_Group.Domain='MYDOMAIN',Name='MYADGROUP'") get
PartComponent

wmic /NODE:LocaServer path Win32_groupuser WHERE (GroupComponent =
"Win32_Group.Domain='LocalServer',Name='MYLOCALGROUP'") get PartComponent

Here's my attempt at a Powershell equivalent

$computer = "LocalServer"
$groupname = "Administrators"
$domain = "LocalServer"
Get-WMIObject -computername $computer Win32_GroupUser | where
{$_.GroupComponent -eq
"\\$computer\root\cimv2:Win32_Group.Domain=""$domain"",Name=""$groupname"""}

For AD change parameters
$domain = "MyDomain"
$groupname = "MyADGroup"

The Powershell equivalent works fine for local groups but doesn't return
data for AD group query. I know I can use DirectoryServices for AD queries,
but I'd rather stick with using WMI for both local and AD group queries.

Also is there a way to call wmic directly from Powershell like I can in the
in bat files?

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Is there a way to query DNS from powershell? PowerShell
LDS query via powershell PowerShell
PerfMon PowerShell Query PowerShell
Running WMI Query in without Powershell or VBS PowerShell
Query NT4 Domain from Powershell PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46