Powershell Scripting

One line powershell script to read in a list of users and change password to a generic password
coolc23Asked:
Who is Participating?
 
Chris DentConnect With a Mentor PowerShell DeveloperCommented:
> Why would this not work?

Depends what you have in users.csv :)

If it were like this:
Username,Name,EmployeeID
BobC,Bob Chaplin,123456

Open in new window

You might get something along the lines of:
$NewPassword = "SomeNewPassword" | ConvertTo-SecureString -AsPlainText -Force
Import-Csv yourfile.csv | ForEach-Object {
  Get-ADUser -Filter { SamAccountName -eq $_.Username } | Set-ADAccountPassword -NewPassword $NewPassword -Reset
}

Open in new window

Finding users with blank employeeID fields is little different, although I should note now that I haven't tested anything here:
# Either:
Get-ADUser -Filter { EmployeeID -NotLike '*' }
# Or:
Get-ADUser -LdapFilter "(!(employeeID=*))"

Open in new window

Chris
0
 
coolc23Author Commented:
hello, and thank you.
0
 
coolc23Author Commented:
One or two line powershell script to find out if the employeeid field is blank in active directory
0
Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

 
prashanthdCommented:
Hi,

You would query on a list of users for both password change and id check?
0
 
coolc23Author Commented:
Yes I wrote something like this: import-csv users.c sv |set-aduser $_.Identity -reset .......
 Why would this not work?
0
 
coolc23Author Commented:
Yes I wrote something like this: import-csv users.c sv |set-aduser $_.Identity -reset .......
 Why would this not work?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.