Breaking News

PowerShell Local admins PS Script

If you want to know the local admins in workstations and servers in your company / OU, you must copy my script to Windows PowerShell ISE and Run As Administrator.

#Make your own computers list and save it in your desktop with computers.txt name and format

$servers = Get-Content ‘C:\Users\%username%\Desktop\computers.txt

$output = ‘C:\Users\%username%\Desktop\finish.csv

$results = foreach ($server in $servers) {

    $group = [ADSI]”WinNT://$server/Administrators”

    $group.Invoke(‘Members’) | % {

        $path = ([adsi]$_).path

        [pscustomobject]@{

            Computer Name = $server

            Domain / Local = $(Split-Path (Split-Path $path) -Leaf)

            User = $(Split-Path $path -Leaf)

        }

    }

}

$results | Export-csv $Output -NoTypeInformation

#Check your Desktop and check your finish.csv file after finished process of script

About The Author