I am having an issue in this power shell script getting the script to oly look at the local accounts on the system. As written it polls AD for every computer and that would put way too much strain on AD. I believe I need to add -Filter "LocalAccount='$True' for the Get-Wmiobject but cant seem to get it in the right place. Any assistance or advice is appreciated. Also I thing that this script is actually doing the work twice to produce a csv output, any suggestions?

```
$Computers = Get-QADComputer -SizeLimit 0 | select -Expand name
    }

function Get-Admins {

Foreach ($Computer in $Computers){
$Online = Test-Connection -ComputerName $Computer -Quiet
    if ($Online -eq "True"){
    $GroupName = Get-WmiObject win32_group -ComputerName  $Computer | ? {$_.SID -eq 'S-     1-5-32-544'} | Select-Object name -ExpandProperty name
    $LocalGroup =[ADSI]"WinNT://$Computer/$GroupName"
    $GroupMembers = @($LocalGroup.psbase.Invoke("Members"))
    $Members = $GroupMembers | foreach {$_.GetType().InvokeMember("Name",   'GetProperty', $null, $_, $null)}
    foreach ($Member in $Members){
    $obj = New-Object System.Object
    $obj | Add-Member -MemberType NoteProperty -Name "Computer" -Value $Computer
    $obj | Add-Member -MemberType NoteProperty -Name "Local Admin" -Value $Member
    $obj
        }
    }
}
 }

Get-Admins | group { $_.Computer } | ForEach-Object {
  $computer = @($_.Group | Select-Object -Expand Computer)[0]
  $admins   = ($_.Group | Select-Object -Expand "Local Admin") -join ','
   '{0},{1}' -f $computer, $admins
 } | Out-File 'c:\scripts\CSV_Admin_export.csv'

```