1, query whether a single account expires: You can use the command net user%USERNAME%/domain to query. Here's how it works:
2. Query the ad account password expiration time for all active: Run the PowerShell tool on AD domain control.
The first step is to enter:
$maxPasswordAge = (get-addefaultdomainpasswordpolicy). Maxpasswordage.days
Enter the second step:
Get-aduser-filter {enabled-eq $True-and passwordneverexpires-eq $False}–properties * |
Select-object-property "Displayname", @{n= "expirydate"; e={$_. Passwordlastset.adddays ($maxPasswordAge)}}
Returns the expiration date for all AD accounts in this domain after a carriage return.
3, through the script to query the ad account for a period of time expired status:
1, in the C-drive path to create a script folder within the placement of scripts getaduserpasswordexpiration.psm1, files in this document attachment. After the power shell is executed by an administrator:
The first method:
First step input:import-module C:\Script\GetADUserPasswordExpiration.psm1
Second Step input:get-oscaduserpasswordexpiration-samaccountname "Doris", "Katrina"-nextday
Note: Doris,katrina is the user account information in the ad domain, which can be modified according to the actual situation.
The second method:
Create a file named Samaccountname.csv in the Script folder under the C-drive path, and open it in the folder by using TXT to save the account information like the following format, the specific account name is subject to actual.
First step input:import-module C:\Script\GetADUserPasswordExpiration.psm1
Step Two input: Get-oscaduserpasswordexpiration–csvfilepath C:\Script\SamAccountName.csv-NextDay 10
The example diagram is as follows:
Data Source:
1. To inquire whether a single account has expired, you can use the following command: NET user%USERNAME%/domain
2. Check the expiration time of all active ad account passwords:
One-liner:get a List of AD Users Password expiry Dates
Http://blogs.technet.com/b/poshchap/archive/2014/02/21/get-a-list-of-ad-users-39-password-expiry-dates.asp
RELATED links:
How to Find when A User Password Expires?
https://theucguy.net/how-to-find-when-a-user-password-expires/
How to check if Active Directory user password are expired on specified days
Https://gallery.technet.microsoft.com/scriptcenter/How-to-check-if-Active-f27b7d39
Note: script for this tool, 22208 for the initial script information can also be used with a little editing.
Ad Password Expiration query