Solved

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

Posted on 2014-10-27
6
169 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 68

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This article will help you understand what HashTables are and how to use them in PowerShell.
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…
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…

910 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

17 Experts available now in Live!

Get 1:1 Help Now