
PowerShell Basics: List Users with Expired Passwords
A basic PowerShell script that can come in handy is one that reviews a list of all users in your Active Directory domain with expired passwords. You can use this to create reports, or even send as attachments to say, your Slack on Monday’s before your Helpdesk starts getting folks screaming they can login.
Run the following PowerShell script as an admin:
get-aduser -filter * -properties passwordlastset, passwordneverexpires |ft Name, passwordlastset, Passwordneverexpires
This will load the Active Directory module into PowerShell, and print a list of users with expired passwords.
If you want to export this into a CSV file, you can run the script with an export pipe like this:
get-aduser -filter * -properties passwordlastset, passwordneverexpires |ft Name, passwordlastset, Passwordneverexpires | Export-csv -path C:\Users\dave\Desktop\user-password-info.csv
Makes sure you update the export path on that script 🙂
Hope you find this helpful!
Categories
Recent Posts
- PowerShell: How to Add an Alias to Every Users Mailbox and Groups in Microsoft 365
- Slack: Disable Entra ID User using a slash command.
- Slack: Retrieve Entra ID (MS365) User Information with a slash command.
- Jira Cloud: Disabling Entra ID User Accounts via Automation and Microsoft Runbook
- Jira Cloud: Restart an Azure VM using JSM Assets and Automation