top of page

PowerShell - Discover Local admins from text list of servers/computers

  • Writer: Jon Boyette
    Jon Boyette
  • Jan 10, 2022
  • 1 min read

This saved as a .ps1 or copy and pasted in a PowerShell Window Get-Content from c:\temp\servers.txt and outputs all the local admins output to c:\temp\admins


$servers= get-content 'c:\temp\servers.txt'

$output = 'c:\temp\admins.csv'

$results = @()


foreach($server in $servers)

{

$admins = @()

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

$members = @($group.psbase.Invoke("Members"))

$members | foreach {

$obj = new-object psobject -Property @{

Server = $Server

Admin = $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)

}

$admins += $obj

}

$results += $admins

}

$results| Export-csv $Output -NoTypeInformation



 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page