Solved

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

Posted on 2011-02-11
8
952 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
  • 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
 
LVL 5

Expert Comment

by:alreadyinuse
ID: 34875669
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 5

Expert Comment

by:alreadyinuse
ID: 34875686
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This article runs through the process of deploying a single EXE application selectively to a group of user.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

820 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