开发者

Find User in Group on Computer [Powershell]

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜