$userName = "your_username"
$user = Get-LocalUser -Name $userName
if ($user.PasswordNeverExpires) {
Write-Host "$userName has 'Password never expires' set to true."
} else {
Write-Host "$userName has 'Password never expires' set to false."
}
Replace "your_username" with the actual username you want to check. The PasswordNeverExpires
property of the Get-LocalUser
cmdlet will be True
if the password never expires, and False
otherwise.
@Sergio Siqueira