Skip to content

Instantly share code, notes, and snippets.

@xillwillx
Created April 18, 2019 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xillwillx/f606d69f57835bf55993eca3a54af7f8 to your computer and use it in GitHub Desktop.
Save xillwillx/f606d69f57835bf55993eca3a54af7f8 to your computer and use it in GitHub Desktop.
list local admin accounts
$admins = Gwmi win32_groupuser –computer 127.0.0.1;$admins = $admins |? {$_.groupcomponent –like '*"Administrators"'}; $admins |% {$_.partcomponent –match “.+Domain\=(.+)\,Name\=(.+)$” > $nul;$matches[1].trim('"') + “\” + $matches[2].trim('"') | Select-Object @{Name='Account Name';Expression={$_}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment