shellgeek.com
Open in
urlscan Pro
2606:4700:3035::6815:3ec0
Public Scan
URL:
https://shellgeek.com/find-get-aduser-password-expiration-date/
Submission: On December 03 via manual from US — Scanned from US
Submission: On December 03 via manual from US — Scanned from US
Form analysis
2 forms found in the DOMGET https://shellgeek.com/
<form method="get" class="search-form navigation-search" action="https://shellgeek.com/">
<input type="search" class="search-field" value="" name="s" title="Search">
</form>
GET https://shellgeek.com/
<form method="get" class="search-form" action="https://shellgeek.com/">
<label>
<span class="screen-reader-text">Search for:</span>
<input type="search" class="search-field" placeholder="Search …" value="" name="s" title="Search for:">
</label>
<input type="submit" class="search-submit" value="Search">
</form>
Text Content
Skip to content ShellGeek Menu * Home * PowerShell * PowerShell Tips * Docker * Microsoft Services * Office 365 * Microsoft 365 * Outlook * About Us * Home » PowerShell » Get-AdUser Password Expiration Date with PowerShell GET-ADUSER PASSWORD EXPIRATION DATE WITH POWERSHELL April 14, 2024October 20, 2023 by shelladmin The Get-ADUser cmdlet retrieves one or more active directory user information. The Get-AdUser command has msDS-UserPasswordExpiryTimeComputed attribute that contains the ad user password expiration date. Active Directory Get-ADUser cmdlet has pwdlastset and passwordlastset attributes which provide information about the password’s last set date. An administrator needs to get ad user password expiration date and notify users about the password expiration date to prevent the account from being locked out. Notify User about Password Expire Days In this article, I will explain how to use the PowerShell Get-AdUser cmdlet to get aduser password expiration date and export user password expiration details to a CSV file. Table of Contents hide 1 How to Get-AdUser Password Expiration Date with PowerShell 2 Conclusion HOW TO GET-ADUSER PASSWORD EXPIRATION DATE WITH POWERSHELL To get aduser password expiration date using PowerShell, run the below command Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties DisplayName, msDS-UserPasswordExpiryTimeComputed | Select-Object -Property Displayname,@{Name="Expiration Date";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties DisplayName, msDS-UserPasswordExpiryTimeComputed | Select-Object -Property Displayname,@{Name="Expiration Date";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties DisplayName, msDS-UserPasswordExpiryTimeComputed | Select-Object -Property Displayname,@{Name="Expiration Date";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} The Get-AdUser command gets a list of active directory users. It uses the -Filter parameter to get only enabled users with the PasswordNeverExpires attribute set to False. The first command gets aduser displayname and msDS-UserPasswordExpiryTimeComputed property to use for password expiration date. The second command, Select DisplayName and convert msDS-UserPasswordExpiryTimeComputed attribute value from large integer data type to date time format and pass output to the third command. The third command displays the active directory user name, ad user password expiration date on the console as below. Get-AdUser Password Expiration Date You can export the adusers password expiration date using the following command. Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties DisplayName, msDS-UserPasswordExpiryTimeComputed | ` Select-Object -Property Displayname,@{Name="Expiration Date";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} | ` Sort-Object "Expiration Date" | Export-Csv -Path C:\adusers-password-expiration-date.csv -NoTypeInformation Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties DisplayName, msDS-UserPasswordExpiryTimeComputed | ` Select-Object -Property Displayname,@{Name="Expiration Date";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} | ` Sort-Object "Expiration Date" | Export-Csv -Path C:\adusers-password-expiration-date.csv -NoTypeInformation Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties DisplayName, msDS-UserPasswordExpiryTimeComputed | ` Select-Object -Property Displayname,@{Name="Expiration Date";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} | ` Sort-Object "Expiration Date" | Export-Csv -Path C:\adusers-password-expiration-date.csv -NoTypeInformation In the above PowerShell script, it uses Export-Csv cmdlet to export the adusers name and password expiration date. CONCLUSION I hope the above article on using the PowerShell Get-ADUser cmdlet to get-aduser password expiration date helpful and educational. You can use the PowerShell script to get active directory users’ expiration dates and export them to the CSV file. The Get-AdUser command has an Enabled attribute that checks the active directory user enabled status like the user is active or disabled. Read more here if you want to get disabled users in the active directory. The Get-Aduser msDS-UserPasswordExpiryTimeComputed attribute contains a large integer datatype value of password expiration date which needs to be converted to datetime before we use it. You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page. Categories PowerShell Outlook Logging – Enable Logging for Troubleshooting Get-ADComputer Last Logon using PowerShell Search for: RECENT POSTS * How to View Docker Container Logs * How to Remove a Docker Container * How to Stop a Running Docker Container FOOTER * Home * About Us * Dsquery * Contact * Privacy Policy * Terms and Conditions Copyright © 2024 ShellGeek All rights reserved