开发者

Find User in Group on Computer [Powershell]

开发者 https://www.devze.com 2023-02-11 19:09 出处:网络
How do I find a user in a group on a particular computer using PowerShell?开发者_JAVA百科 not using active directory, I don\'t have access to the AD server.This uses WMI to find all the users in the

How do I find a user in a group on a particular computer using PowerShell?

开发者_JAVA百科

not using active directory, I don't have access to the AD server.


This uses WMI to find all the users in the local Administratros group on a remote PC. Tear it apart and use the pieces if it helps:

 function get-localadmin { 
 param ($strcomputer) 

 $admins = Gwmi win32_groupuser –computer $strcomputer  
 $admins = $admins |? {$_.groupcomponent –like '*"Administrators"'} 

 $admins |% { 
 $_.partcomponent –match “.+Domain\=(.+)\,Name\=(.+)$” > $nul 
 $matches[1].trim('"') + “\” + $matches[2].trim('"') 
  } 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号