I have a function:
function getlocaladmin {
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('"')
}
}
Doing 'getlocaladmin computer name' is going to take way too long.
I tried:
Get-ADComputer -filter * |
Foreach-Object {
$function:getlocaladmin = $using:funcDef
getlocaladmin $_.name
} |
Export-Csv -Path .\localadmins.Csv
It... did not like that. What can I do to pass it a list of all the computers we have?