Trying to change a remote Windows Password using explicit credentials with PowerShell.
I've been able to make this work using the ADSI interface, but the script is running from a non-elevated account, and therefore does not have permissions. I need to ask the user for an elevated account, and then use that account when making the connection.
This works:
$server = "Server1"
$adminID = "Administrator"
$Password = "NewPassword"
$OldPassword = "OldPassword"
([ADSI] "WinNT://$server/$adminID").SetPassword($Password)
But, I need to also include the old password for the account, so that I have permissions to make the change.
Is there a way to make the connection to the server as $AdminD
with the $OldPassword
, and then change it to $NewPassword
?