I am facing an issue while changing the 150 VMs Local Administrator Password.
When i am trying to change the password first time being able to do that.
But when i am trying to change the password the second time means running the same script i getting the error Access Denied.
This means After changed the password by PowerShell it showing successfully but after that, i am unable to connect to any server to resolved that issue I have to reset the password manually of the administrator
What is exactly issue not able to find. Please Look into this
How did you change the password remotely, can you share the code removing sensitive data. It will help folks in understanding the problem better.
If you are using credentials to connect to the VM and password for that same credential is modified then you will have to use the new changed password to connect again.
I tried 4 Methods:- on First time able to change the password but after that not able to connect to any server
to resolve that issue i have to reset the password manually,
All methods is behaving the same
###########################################################################
What is the logged in user in the system where you executed the script. Is that user and the user whose password being change are same ? are them both has the name Administrator ?
@kvprasoon
I am trying on Workgroup Servers, all are in the workgroup when i am getting this issue so i am trying on 2 servers only currently, There are Domain servers but till now I didn’t try on that
I logged in with the Administrator from where I am executing the script
Running with Administrator User and change the Administrator Password of other Workgroup Server
So mostly thats the reason. Always sue -Credential with Invoke-Command when in workgroup, especially changing password of a user with the same name as current logged in user.
When you don’t use a Credential, Invoke-Command uses current logged in user. In this case the user name is same , Administrator and password was also same once, but changed for other VMs.
I got the server from a client that is the first time and i executed the script first time on the server remotely and was able to change the password without -Credential take the example below script i Run
Invoke-Command -ComputerName $computerName -ScriptBlock { net user Administrator ‘Password’}
or
Method 2 or Method 3 i used
Now Password is changed able to take RDP with New Password
Now I run a same script or i run the simple script like the below script then I am getting error
To connect to a remote system, PowerShell needs to be authenticated. When you do Invoke-Command by default run as the logged in user or the user which is used to launch the PowerShell process.
Here what I think happened is, first time it connected to all the servers as the server you are trying to connect and the server where the script is executing has the same user and password. Next time when you execute, the user is same but password is changed at the other end.
If above is the case, then its always better to use -Credential.
I run the Invoke-command with simple hostname and get-date and working
I change the password
Now its not working
not connecting to server
To resolve this issue i have to reset the password manually after that it work.
I am not able to understand after changing the password by powershell it should connect with powershell also but not connecting