Automating Local Administrator Password Changes on Windows Machines with PowerShell

Table of Contents

Introduction

PowerShell is a powerful scripting language that can be used to automate various tasks, including managing Windows machines. One common task is changing the local administrator account password on multiple machines. This can be a tedious and time-consuming task if done manually, but PowerShell can make it much easier and faster.

Script Overview

The PowerShell script I provided can be used to change the local administrator account password on a list of remote machines or by scanning the network for active machines. Let’s take a closer look at how the script works.

Setting the New Password and Computer List

First, we specify the new password for the local administrator account and the path to the file containing the list of remote machines (if using the hostname list method). These values can be updated as needed to fit your specific requirements.


					
				

Looping Through the List of Remote Machines

Next, we read the list of remote machines from the text file (if using the hostname list method) and loop through each machine in the list.


					
				

Changing the Local Administrator Account Password

For each machine, we use PowerShell remoting to connect to the remote computer and change the local administrator account password using the Set-LocalUser cmdlet. This cmdlet allows us to specify the username (in this case, “Administrator”) and the new password as a secure string.


					
				

Network Scanning

If using the network scanning method, the script uses the Test-Connection cmdlet to ping each IP address in the specified range and check for active machines. Then, it loops through each active machine and changes the local administrator account password using the same method as before.


					
				

Full Script


					
				
Total
0
Shares
Previous Post

User PowerShell To Bulk Change users Password

Next Post

Delete Old User Profiles in Windows

Related Posts

How to Convert ESD to WIM File on Windows

In this tutorial, we will show you how to convert ESD to WIM file from the Command prompt, using the DISM tool, or PowerShell scripts. ESD file is a new highly compressed image distribution format developed by Microsoft. The ESD (Electronic Software Download) image files are used to deploy the Windows operating system instead of
Read More

Copy Files and Folders to User Computers via GPO

You can use Group Policies to copy specific files and folders to user computers in the Active Directory domain. You can place files on the Desktop, in a particular user profile directory, or in any other folder on a local drive. With GPO, you can automatically copy and update various configuration files, INI files, app
Read More