Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- This script list the member of the Administors group for a machine passed in parameter
- #>
- function Get-LocalAdmin
- {
- param ($strcomputer)
- $admins = Gwmi win32_groupuser –computer $strcomputer
- $admins2 = $admins |? {$_.groupcomponent –like '*"Administrators"'}
- if($admins2 -eq $null)
- {
- $admins2 = $admins |? {$_.groupcomponent –like '*"Administrators"'}
- }
- $admins |% {$_.partcomponent –match “.+Domain\=(.+)\,Name\=(.+)$” > $nul
- $matches[1].trim('"') + “\” + $matches[2].trim('"')}
- }
- Export-ModuleMember -Function Get-LocalAdmin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement