On Windows 10 22H2, this works for me :
Get-WmiObject -Class Win32_UserAccount -Filter "Name='your_username'" | Select-Object Name, PasswordExpires
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Guys
How do I check if the local user has "password expires" true or false?
Thank you very much in advance
On Windows 10 22H2, this works for me :
Get-WmiObject -Class Win32_UserAccount -Filter "Name='your_username'" | Select-Object Name, PasswordExpires
# Specify the username you want to check
$userName = "YourUsername"
# Get information about the local user
$user = Get-LocalUser -Name $userName
# Check the PasswordNeverExpires property
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 "YourUsername" 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