← script library

Audit the Local Administrators Group with PowerShell

Security & AuditingAugust 17, 2026

Lists every member of the local Administrators group with its object class and principal source, resolving the group by its well-known SID so the script also works on a localized Windows. Orphaned SIDs — deleted accounts still sitting in the group — are called out separately, and the member list is handed to the next runbook step.

powershell
# Audit Local Administrators
# Single use case: list every member of the local Administrators group
#-----------------------------------------------------------------

function Write-Log {
    param($Message)
    Write-Host "<WRITE-LOG = `"*$Message*`">"
}

# SID S-1-5-32-544 = Administrators (name-independent, works on localized OS)
$group = Get-LocalGroup -SID "S-1-5-32-544" -ErrorAction SilentlyContinue
if ($null -eq $group) { Write-Log "Could not resolve the Administrators group!"; return }

$members = Get-LocalGroupMember -Group $group.Name -ErrorAction SilentlyContinue
if (-not $members) {
    Write-Log "Could not enumerate members (orphaned SIDs can break enumeration on some builds)."
    return
}

Write-Log "================ Local Administrators ($(@($members).Count)) ================"
foreach ($m in ($members | Sort-Object ObjectClass, Name)) {
    Write-Log "[$($m.ObjectClass)] $($m.Name) (source: $($m.PrincipalSource))"
}

$orphans = $members | Where-Object { $_.Name -match "^S-1-5-21-" }
if ($orphans) {
    Write-Log "WARNING: $(@($orphans).Count) orphaned SID(s) found - deleted accounts still in the group!"
}

Write-Log "Local administrator audit complete."

# Pass the member list to the next runbook script
$store = (($members | ForEach-Object { $_.Name }) -join ",")

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.