Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / Active Directory / Extend an Expired User Password in Active Directory

December 23, 2024

Extend an Expired User Password in Active Directory

The password policy, which is enabled by default in Active Directory, sets a maximum age for a user’s password. If the password age exceeds this value, it is considered expired, and the user must change it at the next login.

The administrator can extend the password expiration date when a domain user cannot change their expired password (for example, when a user connects to a corporate network via VPN or RDS) without enabling the Password never expires option for the account.

Use PowerShell to check the expiration date of the user’s password in AD:

Get-ADUser -Identity e.herrmann -Properties msDS-UserPasswordExpiryTimeComputed, PasswordLastSet, PasswordNeverExpires, PasswordExpired |Select-Object -Property Name,PasswordLastSet, PasswordNeverExpires, PasswordExpired,@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}

PowerShell: find out if AD user password expired

In this case, the user’s password has expired( PasswordExpired=True ). The password expiration date is stored in a computed attribute named msDS-UserPasswordExpiryTimeComputed. This attribute’s value is calculated based on the value of the pwdLastSet parameter and the resulting password policy that applies to the user.

Get-ADUser e.herrmann -Properties pwdLastSet | select SamAccountName,@{Name="pwdLastSet";Expression={[datetime]::FromFileTime($_.pwdLastSet)}}

powershell: get ad user password last set

The pwdLastSet attribute contains the date in millisecond format (Windows NT time). However, it can take one of the following special values:

  • 0 – reset the pwdlastset value (means the password was never set)
  • -1 – reset the user password change date to the current time

To change the value of the user attribute, use the Set-ADUser PowerShell cmdlet. First, you have to set 0 and then -1.

Set-ADUser e.herrmann -Replace @{pwdLastSet='0'}
Set-ADUser e.herrmann -Replace @{pwdLastSet='-1'}

Now let’s check the user’s password change and expiration dates. The password change date has been changed to the current date, and the user’s password expiration date has been extended.

Extend expired AD user password using PowerShell:

It is impossible to set a specific password change date in AD.

This method of extending user passwords can also be used if you plan to enable a domain password expiration policy after user passwords have been set to never expire or the PasswordNeverExpires option has been enabled. Enabling this policy will force all users to change their passwords simultaneously, potentially disrupting work processes Before applying this policy, extend the password expiration date for all users as instructed.

2 comments
11
Facebook Twitter Google + Pinterest
Active DirectoryPowerShell
previous post
Fix: Windows Update Tab (Button) is Missing from Settings
next post
Hardware Graphics Acceleration Causes Visual Glitches in Microsoft Office Apps

Related Reading

Exclude a Specific User or Computer from Group...

March 16, 2025

Configure DNS Scavenging to Clean Up Stale DNS...

April 25, 2024

Collecting Windows and Active Directory Event Logs with...

February 7, 2025

Check Windows 11 Hardware Readiness with PowerShell Script

May 15, 2024

Unlocking Active Directory User Accounts

March 12, 2024

Error: The Specified Domain Doesn’t Exist or Couldn’t...

January 23, 2024

AD Domain Join: Computer Account Re-use Blocked

March 16, 2025

Configure NTP Time Source for Active Directory Domain

May 13, 2025

2 comments

Martin December 26, 2024 - 12:28 pm

#for one user
import-module activedirectory

#Change my.user with the target user account.
$username = “user.name”

#This command will get the current PwdLastSet value.

$User = Get-ADUser $username -properties pwdlastset
#Display the current password last set date (convert date to human readable):
[datetime]::fromFileTime($user.pwdlastset)

#Change the user’s pwdlastset attribute to 0
$User.pwdlastset = 0

#Apply the changes against the object
Set-ADUser -Instance $User

#Change the user’s pwdlastset attribute to -1
$user.pwdlastset = -1

#Apply the changes against the object
Set-ADUser -instance $User

#Read again the value from AD
$User = Get-ADUser $username -properties pwdlastset

#Current password last set date, it should be displaying today (convert date to human readable):
[datetime]::fromFileTime($user.pwdlastset)

Reply
Martin December 26, 2024 - 12:30 pm

##for all in OU
Import-Module ActiveDirectory
$ADUserParams=@{
‘Searchbase’ = ‘OU=Users,DC=domain,DC=local’
‘Filter’ = ‘*’
‘Properties’ = ‘cn’,’sn’,’givenname’,’displayName’,’mail’,’description’,’UserPrincipalName’, ’employeeNumber’, ‘profilepath’, ‘title’
}

$ADUsers = Get-ADUser @ADUserParams
ForEach ($ADUser in $ADUsers) {

$ADUser = Get-ADUser $ADUser -properties pwdlastset
$ADUser.pwdlastset = 0
Set-ADUser -Instance $ADUser
$ADUser.pwdlastset = -1
Set-ADUser -instance $ADUser

Get-ADUser -Identity $ADUser -Properties PwdLastSet | Select-Object -Property “Name”, @{n=”PwdLastSet”;e={[datetime]::FromFileTime($_.”PwdLastSet”)}}
}

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Encrypt Any Client-Server App Traffic on Windows with Stunnel

    June 12, 2025
  • Failed to Open the Group Policy Object on a Computer

    June 2, 2025
  • Remote Desktop Printing with RD Easy Print Redirection

    June 2, 2025
  • Disable the Lock Screen Widgets in Windows 11

    May 26, 2025
  • Configuring Windows Protected Print Mode (WPP)

    May 19, 2025
  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Allow Non-admin Users RDP Access to Windows Server
  • Configure Windows LAPS (Local Administrator Passwords Solution) in AD
  • Refresh AD Groups Membership without Reboot/Logoff
  • How to Disable NTLM Authentication in Windows Domain
  • Enable Single Sign-On (SSO) Authentication on RDS Windows Server
  • How to Add, Set, Delete, or Import Registry Keys via GPO
  • How to Reset Active Directory Domain Admin Password
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top