question

GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 asked IanXue-MSFT edited

Password change details

Hi All

i have 10 AD accounts in csv file, i want to get the below information..

Password last set
Password expires
Password changeable
Password required
User may change password

if i use this syntax for one user net user user1 /domain i am able to fetch the information.
i want to import the csv file and export the above information. please guide me. my csv file is in below format

users
user1@contoso.com
user2@contoso.com

windows-serverwindows-active-directorywindows-server-2019windows-server-2016windows-server-2012
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.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT edited

Hi,

You can try some PowerShell script like this.

 $userfile = "C:\temp\user.csv"
 $infofile = "C:\temp\info.txt"
 Import-Csv -Path $userfile | ForEach-Object {
     $_.users
     $pattern = [regex]::new('^.+(?=@)')
     $user=$pattern.Matches($_.users).Value
     net user $user /domain | Where-Object {$_ -match "Password"}
     ""
 } | Out-File -FilePath $infofile

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.