Hi All
I refereed the below post and came up with the below code for changing the password for a user
$Command = "sudo passwd TestUser"
$Command1 = (Invoke-SSHStreamExpectAction -ShellStream $stream -Command $Command -ExpectString "(current) UNIX password:" -Action "test" -TimeOut 10)
sleep -s 2
$stream.Read()
$Command2= (Invoke-SSHStreamExpectAction -ShellStream $stream -Command $Command -ExpectString "New password:" -Action "Password1" -TimeOut 10)
$Command3= (Invoke-SSHStreamExpectAction -ShellStream $stream -Command $Command -ExpectString "Retype new password:" -Action "Password1" -TimeOut 10)
The Password is changing..but the problem is it is not changing as per mentioned in the -Action. when i am going back and try to login using both old and new password i am not able to.
Can anyone help me here.
www.reddit.com/.../
Personally, I've not had a reason to use this cmdlet/module, since Windows 10 allows the use of bash natively via WSL/Ubuntu or other Linux versions from teh Windows App Store, so why not just use that.
Install Windows Subsystem for Linux (WSL) on Windows 10https://docs.microsoft.com/en-us/windows/wsl/install-win10
Example of bash commands fro password changes:https://www.systutorials.com/39549/changing-linux-users-password-in-one-command-line
As for ...
"The Password is changing..but the problem is it is not changing as per mentioned in the -Action. when i am going back and try to login using both old and new password i am not able to."
So, some reset action is happening since you cannot use the old password any longer.As for not being able to use the new passwords, says, the password was never set to what you sent, but something else or blanked out because of some potential errant action/activity or unreported failure.
Thanks for the response.
As for Win10, it is not mandatory that the script will run on win10. it can go to any win machine as i am going to provide the exe for this script. So using any other resource will not cut it out in my situation as it is very specific with the need.
and i just wanted to know as u said password is going something else or blanked out, need to know what is going or how to resolve this issue.