Logged-in to $ComputerName
as local Administrator Windows Server 2008 R2 SP1
This script :
$admin=[adsi]("WinNT://" + $ComputerName + "/administrator, user")
$admin.psbase.invoke("SetPassword", $Password)
$admin.psbase.CommitChanges()
run locally throws exception : Exception calling "Invoke" with "2" argument(s):"The network path was not found"
In the Command Prompt window, type the password reset command: net user <username> <password> and hit Enter to set a new password for your Windows 10 local admin account. Once password reset is complete, close the Command Prompt and then you can sign into the admin account with the new password.
To add the AD user or the local user to the local Administrators group using PowerShell, we need to use the Add-LocalGroupMember command. You can also add the Active Directory domain user to the Local Administrators group by providing the domain name if the computer is in the same domain.
When I wanted to change local admin password accross all the servers in AD domain I simply used PS remoting which allows pushing even very basic commands from CMD to remote server.
I wrote a short script where I use powershell to obtain info from domain controller and based on certain conditions push command to the servers.
I find it as really easy and fast way how to change local admin password. The only requirement is to have WinRM enabled on all the servers.
The script is below here:
Invoke-Command -ScriptBlock {net user administrator "Password01"} -ComputerName (Get-ADComputer -SearchBase "OU=test,OU=servers,DC=lab,DC=com" -Filter * | Select-Object -Expand Name)
Have not tested this but i found
([adsi]“WinNT://<Local or Remote Computer Name>/<Username>”).SetPassword(“<Password>”)
http://www.petri.co.il/how-to-change-user-password-with-powershell.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With