Powershell Scripting

One line powershell script to read in a list of users and change password to a generic password
coolc23Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
prashanthdCommented:
Hi,

You would query on a list of users for both password change and id check?
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

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
Chris DentPowerShell 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.