Solved

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

Posted on 2014-10-27
6
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 70

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
A hard and fast method for reducing Active Directory Administrators members.
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…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

739 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