Powershell - check local admin user is enabled
Aim: check if local admin user on Windows is enabled using PowerShell.
It’s better to use the SID for the local administrator account instead of the hard-coded English name, Administrator
, because the differs according to language.
1
2
3
4
5
6
7
8
9
10
11
12
13
# get details
PS C:\tmp> $AdminDetails = (Get-LocalUser | ? { $_.SID -like 'S-1-5-21-*-500'})
# print details
PS C:\tmp> $AdminDetails
# output looks like
Name Enabled Description
---- ------- -----------
Administrator False Vordefiniertes Konto . . .
# select the enabled property with
PS C:\tmp> ($AdminDetails) | Select -ExpandProperty "Enabled"
This post is licensed under CC BY 4.0 by the author.