Check Domain Account Expiration Date

As an end-user that does not support active-directory, I like to know when my password is approaching its expiration date; this is also useful if you have a non-human service account created to automate a process – you wouldn’t want the password for the account to expire without you knowing.

The following script can be executed as seen below by calling the script and passing a correct domain username:

The script also handles incorrect usernames:

Here is the script:

If you wanted to take it further, I’d suggest creating some if/else conditions to evaluate $CalculateDays to email out on remaining days or if account is $LockedOut or not.

Leave a Reply

Be the First to Comment!

Notify of