Solved

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

Posted on 2014-10-27
6
175 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 39

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.
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html) provided 218 attendees with a step-by-step guide for identifying Acti…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

786 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