Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell script to Return AD's password status and ask if maintainer wants to change it.

Posted on 2011-02-11
8
Medium Priority
?
957 Views
Last Modified: 2012-05-11
Experts,

        I have a script that searches for an AD user and returns the users path and properties. I want the same script to include the users password status and ask the maintainer if they would like to change password at this time. Password activity needs to be piped out to text file.

        Here is the code I have so far...
$Search = New-Object DirectoryServices.DirectorySearcher([ADSI]“”)
$Search.filter = “(&(objectClass=user)(sAMAccountName=$User))”
$Search.Findall()

Open in new window

0
Comment
Question by:missymadi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:alreadyinuse
ID: 34875526
If your clients are in a domain ,GPO notifications presented on the clients desktop x number of days before it expires. Then they can change them from their workstations.
0
 

Author Comment

by:missymadi
ID: 34875577
This notification needs to be executed immediately. The purpose of the script is for the maintainer to run this script and have a report (printable) and an option to immediately change the password.
0
Introducing the WatchGuard 420 Access Point

WatchGuard's newest access point includes an 802.11ac Wave 2 chipset, providing the fastest speeds for VoIP, video and music streaming, and large data file transfers. Additionally, enjoy the benefits of strong security as the 3rd radio delivers dedicated WIPS protection!

 
LVL 27

Accepted Solution

by:
KenMcF earned 2000 total points
ID: 34876357
What information are you looking to get?
The quest cmdlets can probably do what you are looking for.

$user = read-host "Enter UserName"
Get-qaduser $User | Select PasswordLastSet, PasswordAge,PasswordExpires, PasswordNeverExpires, UserMustChangePassword, PasswordIsExpired, PasswordStatus
0
 

Author Comment

by:missymadi
ID: 34883527
Here is the code I have so far. I have not tested in our lab as of yet.
What is the format/syntax to pipe the user information into a text file?

Thanks, Missymadi
$user = read-host "Enter UserName"
Get-qaduser $User | Select PasswordLastSet, PasswordAge,PasswordExpires, PasswordNeverExpires, UserMustChangePassword, PasswordIsExpired, PasswordStatus 
$User = read-host "Do you want to reset a user's password?"
$strResponse = Read-Host "[1] Yes, [2] No"

If ($strResponse -eq "1" $colComputers = ListComputers | Sort-Object}
***I want to run another script to reset user's password
$users = get-qaduser -samaccountname USERNAME 
$users | %{
set-qaduser -Userpassword 'Test'
get-qaduser -samaccountname $_.samaccountname | Select samaccountname, passwordlastset | out-file c:\PwdChanged.txt -noclobber
}

   else{Write-Host "Good-Bye"

Open in new window

0
 

Author Comment

by:missymadi
ID: 34883553
Nevermind - I had the password file in there ;)

I am going to test the code in our lab now.
0
 

Author Comment

by:missymadi
ID: 34883891
The reason for this script - we have a test LAN, and this script will come in handy to see test user stats and quickly(automatically) reset test users passwords.

Here is my code for the Powershell script. It is not executing how I expected.

1. Enter a username and the username entered password information will be returned.
2. The user is asked if they want to reset a user's password in AD. The reponse should be 1 for yes, 2 no
3. If user entered 1, enter user name and the script will change the users password. The password information should be printed to screen and to out.txt file so the user knows the new password.

$user = read-host "Enter UserName"
Get-qaduser $User | Select PasswordLastSet, PasswordAge,PasswordExpires, PasswordNeverExpires, UserMustChangePassword, PasswordIsExpired, PasswordStatus 
$User = read-host "Do you want to reset a user's password?"
$strResponse = Read-Host "[1] Yes, [2] No"

If ($strResponse -eq "1" )

{$users = get-qaduser -samaccountname USERNAME 
$users | %{
set-qaduser -Userpassword 'Test'
get-qaduser -samaccountname $_.samaccountname | Select samaccountname, passwordlastset | out-file c:\PwdChanged.txt -noclobber
}

   else{Write-Host "Exiting Search Script"}
}

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Here's a look at newsworthy articles and community happenings during the last month.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

715 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