title: Using Remove-Item with Credentials
body: <p>I am attempting to use the Remove-Item cmdlet as part of an automation for a system.  The files are stored on a server that requires elevated rights to perform the file deletion.  I have access to a domain admin account that I use for such automation scripts.</p>
  
  <p>The code below will build the PSCredential object:</p>
  
  <pre><code>$password = New-Object System.Security.SecureString
  "passwordhere".ToCharArray() | ForEach-Object { $password.AppendChar($_) }
  $cred = New-Object System.Management.Automation.PSCredential("domain\username",$password)
  $cred
  </code></pre>
  
  <p>I am passing this object to the following action:</p>
  
  <pre><code>Remove-Item -LiteralPath $path -Force -Credential $cred
  </code></pre>
  
  <p>Any ideas?  </p>