Skip to content

Instantly share code, notes, and snippets.

@nicolonsky
Last active April 21, 2023 23:11
Show Gist options
  • Save nicolonsky/aecd9f0fa689cebf49b623f209f21f38 to your computer and use it in GitHub Desktop.
Save nicolonsky/aecd9f0fa689cebf49b623f209f21f38 to your computer and use it in GitHub Desktop.
$username = "clientadmin"
try {
$user = Get-LocalUser -Name $username -ErrorAction Stop
if ($user.Enabled) {
Write-Output ("User {0} present and enabled" -f $username)
exit 0
}
else {
Write-Output ("User {0} present but NOT enabled" -f $username)
Exit 1
}
}
catch {
Write-Output ("User {0} not found" -f $username)
Exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment