There are a number of options:
Using PowerShell Script with Group Policy
- Create a PowerShell Script: Create a PowerShell script to change the local admin password. Save it as
Change-LocalAdminPassword.ps1
:$newPassword = "YourNewSecurePassword" $adminUsername = "Administrator" $adminUser = [ADSI]"WinNT://./$adminUsername, user" $adminUser.SetPassword($newPassword) $adminUser.SetInfo()
- Store the Script in a Network Share: Place the
Change-LocalAdminPassword.ps1
script in a network share that is accessible to all client computers. Ensure the share has read permissions for the computers. - Create a Group Policy Object (GPO): Open the Group Policy Management Console (GPMC) on your Domain Controller and create a new GPO, for example,
Change Local Admin Password
. - Configure the GPO to Run the Script:
- Edit the newly created GPO.
- Navigate to
Computer Configuration > Policies > Windows Settings > Scripts (Startup/Shutdown)
. - Click on
Startup
, thenAdd
andBrowse
to locate your script. Add the path to the PowerShell script in the network share.
- Allow PowerShell Script Execution: Ensure that the execution policy allows the script to run by configuring the GPO to set the PowerShell execution policy:
- Navigate to
Computer Configuration > Policies > Administrative Templates > Windows Components > Windows PowerShell
. - Enable the
Turn on Script Execution
policy and set it toAllow all scripts
.
- Navigate to
- Link the GPO to the Appropriate OU: Link the GPO to the Organizational Unit (OU) containing the client computers.
Using PsExec
If you need to change the password immediately and cannot wait for the Group Policy to propagate, you can use PsExec from Sysinternals:
- Download and Extract PsExec: Download PsExec from the Sysinternals website and extract it to a folder.
- Run the Command: Use PsExec to run the PowerShell command remotely. Open Command Prompt as an administrator and run the following command:
psexec \computername -u domain\adminusername -p adminpassword powershell -Command "([ADSI]'WinNT://./Administrator, user').SetPassword('YourNewSecurePassword')"
You can replace \\computername
with a list of computers, or use a script to loop through all computers in a text file.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin