title: Powershell - Get-WmiObject filter
body: <p>I need to get local admins on remote machine but need to show only domain users (Users with domain\prefix)</p>
  <pre><code>   $admins = Gwmi win32_groupuser –computer computer   
      $admins = $admins |? {$_.groupcomponent –like '*&quot;Administrators&quot;'} 
      $admins |% {  
      $_.partcomponent –match “.+Domain\=(.+)\,Name\=(.+)$” &gt; $nul  
      $matches[1].trim('&quot;') + “\” + $matches[2].trim('&quot;') 
      } 
  
  $admins = $admins |? {$_.groupcomponent –like '*&quot;Administrators&quot;'}
  
  GroupComponent   : \\COMPUTER\root\cimv2:Win32_Group.Domain=&quot;COMPUTER&quot;,Name=&quot;Administrators&quot;
  PartComponent    : \\COMPUTER\root\cimv2:Win32_Group.Domain=&quot;DOMAIN&quot;,Name=&quot;Domain Admins&quot;
  PSComputerName   : COMPUTER
  </code></pre>
  <p><strong>Current Output:</strong></p>
  <p>COMPUTER\Administrator</p>
  <p>DOMAIN\Domain Admins</p>
  <p>DOMAIN\User1</p>
  <p>DOMAIN\user2</p>
  <p>I need to show only domain users</p>
  <p><strong>Desired Output:</strong></p>
  <p>DOMAIN\Domain Admins</p>
  <p>DOMAIN\User1</p>
  <p>DOMAIN\user2</p>
  <p>I tried this:</p>
  <pre><code>$admins |% {  
  $_.partcomponent –match “.+Domain\='DOMAIN\',Name\=(.+)$” &gt; $nul  
  $matches[1].trim('&quot;') + “\” + $matches[2].trim('&quot;') 
  } 
  </code></pre>
  <p>But single user is shown multiple times</p>
  <p>DOMAIN\User1</p>
  <p>DOMAIN\User1</p>
  <p>DOMAIN\user1</p>