The following is a comparison between the steps involved in changing local user passwords remotely with Windows PowerShell and ADSelfService Plus, a comprehensive password management tool:
Executing this code will reset the password for a single user in Azure Active Directory.
$Password = Read-Host -AsSecureString $UserAccount = Get-LocalUser -Name "User02" $UserAccount | Set-LocalUser -Password $Password No supported.
Once the password change option is configured in ADSelfService Plus, all users can securely change their Active Directory password from the end-user portal.
With ADSelfService Plus, even the VPN and OWA users can change their passwords remotely through a secure web-portal. That means, ADSelfService Plus also updates the cached credentials stored on the user’s machine.
Ensure the target computer is reachable. The script below confirms if RemotePC is online.
Test-Connection -ComputerName "RemotePC" -Count 2Set a new password for a local user. This changes the password for LocalUser on the local machine.
$Password = ConvertTo-SecureString "NewPassword123!" -AsPlainText -Force Set-LocalUser -Name "LocalUser" -Password $PasswordUse PowerShell remoting to change the password remotely. This updates LocalUser’s password on RemotePC.
Invoke-Command -ComputerName "RemotePC" -ScriptBlock {
$Password = ConvertTo-SecureString "NewPassword123!" -AsPlainText -Force
Set-LocalUser -Name "LocalUser" -Password $Password
}Update passwords on multiple computers. The script below updates LocalUser's password on all specified computers.
$computers = @("PC1", "PC2", "PC3")
foreach ($computer in $computers) {
Invoke-Command -ComputerName $computer -ScriptBlock {
$Password = ConvertTo-SecureString "NewPassword123!" -AsPlainText -Force
Set-LocalUser -Name "LocalUser" -Password $Password
}
}Run the script below to reset a local user password remotely. Replace RemotePC with the actual remote system.
Invoke-Command -ComputerName RemotePC -ScriptBlock { net user Administrator "NewPass@123" }Yes, you can change passwords on multiple remote machines by running the script below.
$computers = @("PC1", "PC2", "PC3")
Invoke-Command -ComputerName $computers -ScriptBlock { net user Administrator "NewPass@123" }Yes, you must run PowerShell as an administrator.