Powershell console not executing cmdkey to save password so the mstsc asks for login/pass

63 Views Asked by At

I want to login to windows remote desktop via simple script which

  1. saves the password (so I do not see the prompt dialog asking for credentials)
  2. opens the remote desktop

I have written and save it as a .bat file:

cmdkey /generic:"Wk123" /user:"myLogin" /pass:"myPassword"
mstsc /v:Wk123

After I run it, the remote desktop opens without asking for credentials.

But If I save given script as .ps1 and run it in powershell, the login/pass dialogs opens and I am still beeing asked to enter the password. The dialog says: "The logon attempt failed".

Result from running the command is the same:

CMDKEY: Credential added successfully.

Why same commands work in a .bat file but does not in .ps1 ?

0

There are 0 best solutions below