Solved

need report of users that haven't changed password in 60 days  - Powershell to CSV

Posted on 2015-01-29
3
158 Views
Last Modified: 2015-02-02
need to export all users whos password hasnt been changed in the last 60 days

OU level
0
Comment
Question by:Jorge Ocampo
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
SreRaj earned 500 total points
ID: 40579138
Hi,

Please try following code from AD Module for PowerShell.

Get-ADUser -Filter * -Properties distinguishedname,cn,passwordlastset | where{$_.passwordlastset -ne $null} | where{$_.passwordlastset -le ((get-date).adddays(-60))} | select name,samaccountname,@{n='ParentContainer';e={$_.distinguishedname -replace '^.+?,(CN|OU.+)','$1'}} | export-csv userlist.csv -notypeinformation
0
 
LVL 2

Author Comment

by:Jorge Ocampo
ID: 40579817
where do i specify the OU location what does the -replace do?
0
 
LVL 12

Expert Comment

by:SreRaj
ID: 40583289
You don't need to specify a OU as it runs on the complete domain and creates a list of all users whose last password set is older than 60 days. There will be a column with heading Parent Container which will give the OU name in which user account exists.

Output  of Get-AdUser does not contain Name of the OU for a user account. So this command takes the value in  distinguishedname attribute and trims it to take the OU name from it. -replace is used for this trimming.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
This article will help you understand what HashTables are and how to use them in PowerShell.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now