Solved

Powershell script  that would change  the local admin password on all the  servers in the domain.

Posted on 2014-10-27
6
177 Views
Last Modified: 2015-06-18
We will be going through an audit soon and one of the requirements is to change  the local admin password on all the servers in our Microsoft domain.  So, I think a Powershell script can be used that would change  the local admin password on all the  servers in the domain.  Thanks!  Would appreciate it!
0
Comment
Question by:mjm21
6 Comments
 
LVL 16

Accepted Solution

by:
Joshua Grantom earned 250 total points
ID: 40406601
Here are 2 options, already has these available from a previous incident

You can use this one if you have a list of servers in a text file

$pass = "NewPassword"
$user = "Administrator"
foreach($_ in (Get-Content C:\Servers.txt)){
$newpass = [ADSI]"WinNT://$_/$user,user"
$newpass.SetPassword($pass)
}

Open in new window


Or if you want to do this for all servers in an OU

# Insert desired Password
$pass = "NewPassword"
# Do not Change Username
$user = "Administrator"
#Distinguished Name to OU or CN
$distinguishedname = "CN=Computers,DC=domain,DC=com"
#Finds Computers
$computers = Get-ADComputer -filter * -SearchBase $distinguishedname | Select-Object Name | Where-Object {($_.OperatingSystem -like 'Windows Server*')}| Select -Exp Name
#Loop to change password for each computer
foreach($computer in $computers){
$newpass = [ADSI]"WinNT://$computer/$user,user"
$newpass.SetPassword($pass)
}

Open in new window

0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 250 total points
ID: 40406632
Really simple one liner with psexec

psexec -e -n 5 @serverlist.txt net user Administrator <NewPassword>

Open in new window


flags -e does not load yoru profile
-n specifies a 5 second connection timeout.
0
 
LVL 40

Expert Comment

by:footech
ID: 40406732
You may want to check out the scripts at http://support2.microsoft.com/kb/2962486 to set random passwords.
0
 

Author Comment

by:mjm21
ID: 40406744
Thanks!  Will test!
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40837046
I've requested that this question be closed as follows:

Accepted answer: 250 points for becraig's comment #a40406632
Assisted answer: 250 points for Joshua Grantom's comment #a40406601

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

808 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