Windows PowerShell give password in command Enter-PSSession
powershell, windows
Solution
Yes, you can provide password while opening a `new-pssession` like below
$passwd = convertto-securestring -AsPlainText -Force -String <your password>
$cred = new-object -typename System.Management.Automation.PSCredential
-argumentlist "Domain\User",$passwd
$session = new-pssession -computername <computer> -credential $cred
Problem
I am writing a project where I run a PowerShell script and create a new PSSession as follows: ``` PowerShell.exe -Command enter-pssession myUser -credential userName ``` When I run this, it opens a dialog to prompt the user for a password. However, I would prefer for the user to be able to enter the password along with the rest of the above line instead of having to be bothered with the prompt. I'm very new to PowerShell, and everything I've found in docs only gives ways to bring the prompt up for the password. Is this something that is possible to accomplish in PowerShell? Thanks!