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('"')
}
}
精彩评论