question

VadiveluRamasamy-7465 avatar image
0 Votes"
VadiveluRamasamy-7465 asked AndreasBaumgarten commented

Extract "pwdLastSet, Password expires, Password changeable, Password required, User may change password" property for all Staff OU users

Hi Guys,

Trying to Extract "pwdLastSet, Password expires, Password changeable, Password required, User may change password" property for all Staff OU users and export to csv.

Any advice would be greatly appreciated. Thank you

windows-server-powershell
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @VadiveluRamasamy-7465 ,

are there any additional questions? Does the answer help to solve the issue?
If you found the answer helpful, it would be great if you please mark it "Accept as answer". This will help others to find answers in Q&A


Regards
Andreas Baumgarten

0 Votes 0 ·

1 Answer

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered

Hi @VadiveluRamasamy-7465 ,

the command Get-AdUser should be helpful to get all users of OU:
https://docs.microsoft.com/en-us/powershell/module/activedirectory/get-aduser?view=windowsserver2019-ps#example-1--get-all-of-the-users-in-a-container

With the parameter -Properties * you will get all properties of a user.

Here is a list of all Ad user properties returned by Get-ADUser:
https://social.technet.microsoft.com/wiki/contents/articles/12037.active-directory-get-aduser-default-and-extended-properties.aspx

With the Select-Object command you can filter the properties.

The script could look like this (not tested by myself):

 $users = Get-ADUser -Filter * -SearchBase "OU=STAFF,DC=TEST,DC=LOCAL" | Select-Object <propertyname1>,<propertyname2>,<....>
 $users | Export-Csv -Path "C:\temp\yourcsvfile.csv" -Encoding utf8 -Delimiter ","


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.