title: Powershell Remoting with credential
body: <p>While running remoting commands like <code>Enable-PsSession</code>, <code>Invoke-command</code> etc. we need to provide credentials with those commands. </p>
  
  <p>I don't want to provide the credentials every time while executing these command.</p>
  
  <p>Also lets say I stored the username in variable &amp; using the variable while executing the command. I want to do this for the password as well. Could I do that ?</p>
  
  <p>Eg: </p>
  
  <pre><code>Invoke-Command -ComputerName mycomputer -ScriptBlock { Get-ChildItem C:\ } -credential  mydomain\administrator
  </code></pre>
  
  <p>So here I am providing the password everytime while executing these command.</p>
  
  <p>How should the commands take username &amp; password automatically either from variable &amp; some other mechanism ?</p>