![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | 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 Specs![]() |
![]() |
| 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 | |||