title: Access is denied to localhost despite being administrator - PowerShell
body: <p><br>
  Okay, so this has been bugging me for a while and I have tried too many things now.<br><br>
  I'm trying to run a PowerShell script - my user account is a regular one on the domain, it is however local administrator on my computer. Therefore I've created a PowerShell script prompting me for credentials (where I type the credentials of my domain administrator account) to be used to invoke another script which needs this domain administrator elevation.
  This script looks like this:</p>
  
  <pre><code>Invoke-Command -FilePath "C:\Temp\script.ps1" -ComputerName localhost -Credential Get-Credential
  </code></pre>
  
  <p>Here the <code>script.ps1</code> is the script which needs domain administrator elevation.<br> 
  Executing the shown script results in a prompt for credential and then the following error:</p>
  
  <pre><code>[localhost] Connecting to remote server localhost failed with the following error message : Access is denied.
  </code></pre>
  
  <p>I've tried messing around with a .bat file looking like this: </p>
  
  <pre><code>SET ThisScriptsDirectory=%~dp0
  SET PowerShellScriptPath=%ThisScriptsDirectory%script.ps1 PowerShell -NoProfile -ExecutionPolicy Bypass -Command "&amp; {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%PowerShellScriptPath%""' -Verb RunAs}";
  </code></pre>
  
  <p>aswell, but I can't make it work - it is not elevating the script to domain administrator level.<br>
  Lastly however, I need to mention that the script I want to run with domain elevation works if I open PowerShell with the domain administrator elevation, navigates to C:\Temp\script.ps1 and executes it by .\script.ps1.</p>
  
  <p>Any suggestions?</p>