title: How to get the groups of a local user through powershell script?
body: <p>I am able to get the members of a local group using the following script :</p>
  
  <pre><code>$CompStat = Get-WmiObject win32_computersystem;
  $Localhst = $CompStat.Name;
  $Computer = [ADSI]('WinNT://'+$localhst+',computer');
  $group = [ADSI]('WinNT://'+$Localhst+'/groupname,group');
  $Members = @($group.psbase.Invoke("Members"));
  $Members | ForEach-Object {$MemberNames += $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null);
   Write-Output $MemberNames;
  }
  </code></pre>
  
  <p>Similarly how to get the groups of a particular user?</p>