Group Membership Appears To Hang

Jan 26, 2010 at 11:25 PM
Edited Jan 26, 2010 at 11:34 PM

It looks like the Group Member feature of tool has issues in a large corporate forest/domain which will cause the app to hang.  This appears to be due to the duration of running the following command in the ChangeDescription and ListAllGroups functions:

$Groups = Get-WmiObject Win32_Group | where-Object { $_.LocalAccount -eq $True }

Instead of querying all groups returned by the above call should it be something like the following?

$Groups = Get-WmiObject Win32_Group -filter "LocalAccount=True"

 

########################################################

 function ChangeDescription
{
  #$Groups = Get-WmiObject Win32_Group | where-Object { $_.LocalAccount -eq $True }
 
#change to prevent the long hang for forest with a number of domains and groups...

   $Groups = Get-WmiObject Win32_Group -filter "LocalAccount=True"
 
  foreach ($group in $Groups)
  {
    if ($group.Name -match $ListGroups.SelectedItem)
    {
      $lblDescript.Text = $group.Description
    }
  }
}

 function ListAllGroups
{
 #
 $Groups = Get-WmiObject Win32_Group -filter "LocalAccount=True" # | where-Object { $_.LocalAccount -eq $True }
 foreach ($group in $Groups)
 {
  $ListGroups.Items.Add($group.Name)
  if ($group.Name -match "Administrators")
  {
   $ListGroups.set_SelectedItem($group.Name)  
  }
 }
}