Q:

WMI win32_groupuser slow performance in PowerShell

Not sure if this is me. I wrote a script to check for the existence of a domain group in Local Administrators on remote servers. Due to the existence of over 20 domains in my company--many of them isolated from each other--I'm not sure if this would work using AD cmdlets. Instead, I thought I'd query each server's WMI directly, a solution that usually works for me.
Not in this case. Here's the meat of my script:
$admin = Get-WmiObject win32_groupuser –computername $server | Where-Object $_.PartComponent -match $domaingroup} | Measure-Object

If the group is present, then $admin has a positive count and I can report on that. Otherwise the count is 0 and that's okay too. 
But today, I was asked to check for the existence of the group on 200 servers, and my script failed me. It was dog slow. It would take five to ten minutes to get the result from each server. I can log onto a server and visually check for the group faster than that.
Is this one of those WMI groups that, I don't know, rebuilds an entire database every time it's touched, or something weird? Any suggestions for a faster script?

A:

An alternative is to use an ADSI query, something like:
$Results = ForEach($Server in (Get-Content .\ServerList.txt)){
    $group = [ADSI]"WinNT://$Server/Administrators"
    [PSCustomObject]@{'Server'=$Server
    'Group Found' = [boolean](@($group.Invoke("Members")) |
        foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}|
        Where{ $_ -match $domaingroup}| Measure-Object)
    }
}

That should leave you with an array of server names and True/False if the AD group was found in the local administrators group.

