title: Java - Remotely Connect to a Server using PowerShell and bypass the password prompt
body: <p>I need help connecting to a remote server using PowerShell in JAVA. I want the connection to be done in the background, without having a prompt for the password and navigate to the desired location on the server (C:\Events\rootdir\), where I will upload a directory from my local machine. </p>
  
  <p>Currently, I am using the following query:</p>
  
  <pre><code> String command = "powershell.exe Invoke-Command -Credential myusername -ComputerName 192.x.x.x -FilePath C:\\Events\\rootdir\\
   Process powerShellProcess = Runtime.getRuntime().exec(command);
   powerShellProcess.getOutputStream().close();
  </code></pre>
  
  <p>However, by doing this I am getting a prompt for the password:</p>
  
  <p><a href="https://i.stack.imgur.com/BHa3M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BHa3M.png" alt="enter image description here"></a> </p>
  
  <p>What do I need to do to include the password call in the command string, so that I connect directly to C:\Events\rootdir\, bypassing this password prompt?</p>