Solved

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

Posted on 2014-10-27
6
168 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
Comment Utility
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 28

Assisted Solution

by:becraig
becraig earned 250 total points
Comment Utility
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
Comment Utility
You may want to check out the scripts at http://support2.microsoft.com/kb/2962486 to set random passwords.
0
 

Author Comment

by:mjm21
Comment Utility
Thanks!  Will test!
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now