Question:
Logged-in to $ComputerName
as local Administrator Windows Server 2008 R2 SP1
This script :
1 2 3 4 |
$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"
Answer:
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:
1 2 |
Invoke-Command -ScriptBlock {net user administrator "Password01"} -ComputerName (Get-ADComputer -SearchBase "OU=test,OU=servers,DC=lab,DC=com" -Filter * | Select-Object -Expand Name) |