Reset ComputerMachinePassword - PowerShell


Overview

Reset-ComputerMachinePassword is a PowerShell command that allows you to reset the local computer machine account password. This command is primarily used in situations where the machine account password has been forgotten or compromised, such as during Active Directory domain recovery or troubleshooting authentication issues.

Syntax

Reset-ComputerMachinePassword [-Credential <PSCredential>] [-Force] [-PassThru]

Options/Flags

-Credential

  • Specifies the credentials to use for resetting the machine account password. This parameter is only required if the current user does not have the necessary permissions to reset the password.

-Force

  • Forces the password reset even if the computer is not in a domain.

-PassThru

  • Returns the new machine account password as a secure string.

Examples

Simple Reset

Reset-ComputerMachinePassword

Reset Password Using Credentials

$credential = Get-Credential
Reset-ComputerMachinePassword -Credential $credential

Force Password Reset for Local Computer

Reset-ComputerMachinePassword -Force

Get New Password as Secure String

$newPwd = Reset-ComputerMachinePassword -PassThru

Common Issues

  • Access Denied: Ensure that the user running the command has sufficient permissions to reset the machine account password.
  • Computer Not in Domain: If the computer is not in a domain, the -Force parameter must be used.
  • Invalid Credentials: Double-check the credentials provided using the -Credential parameter.

Integration

Script to Reset Multiple Computers

$computers = Get-ADComputer -Filter *
foreach ($computer in $computers) {
  Reset-ComputerMachinePassword -ComputerName $computer.Name -Credential $credential
}

Using with Netdom

Reset-ComputerMachinePassword
Netdom resetpwd /s:server1.domain.local /ud:username /pd:password