title: PowerShell Invoke-Webrequest / provide password and skip promt
body: <p>I made a script accessing an API which requires authentication. The this is working if I enter the credentials (email+pw) into the prompt:</p>
  
  <pre><code>$cred = Get-Credential 
  $web = Invoke-WebRequest -Uri $srcURI -Credential $cred
  </code></pre>
  
  <p>But this does not allow me to automate this setup, as a prompt is always coming up asking for Username/PW. </p>
  
  <p>I tried several different ways, but none seems to be working:</p>
  
  <p>For me the most logical was:</p>
  
  <pre><code> $username="user" 
   $password="password1"
  
   $PScredOBJ = New-Object -TypeName System.Management.Automation.PSCredential($username,$password) 
   $cred2 = Get-Credential -Credential $PScredOBJ
  </code></pre>
  
  <p>Result: Still an empty prompt showing up.</p>
  
  <p>Anybody knows how to handle this?</p>
  
  <p>Thx</p>