Find Windows Administrators on Server |
|
Run through a list of servers to find out who is administrator on the box
Environment will need WinRM enabled.
foreach($SQL in $Instance)
{
try{
write-host $($sql.servername) -ForegroundColor red -BackgroundColor blue
invoke-command -ComputerName $($sql.servername) -ScriptBlock {
net localgroup administrators | where {$_ -AND $_ -notmatch "command completed successfully"} | select -Skip
}
}
catch [Exception]
{
write-host $errormessage -foreground red -BackgroundColor Yellow
}
}
Environment will need WinRM enabled.
foreach($SQL in $Instance)
{
try{
write-host $($sql.servername) -ForegroundColor red -BackgroundColor blue
invoke-command -ComputerName $($sql.servername) -ScriptBlock {
net localgroup administrators | where {$_ -AND $_ -notmatch "command completed successfully"} | select -Skip
}
}
catch [Exception]
{
write-host $errormessage -foreground red -BackgroundColor Yellow
}
}