title: Why does PowerShell script indicates failure locally even when it executes correctly on remote?
body: <p>When I tested this on the remote machine directly, it works perfectly.</p>
  
  <pre><code>Get-ItemProperty 'IIS:\Sites\Default Web Site\MySite' -Name physicalPath
  </code></pre>
  
  <p>However, when I try using the Invoke-Command syntax from my machine, it fails with</p>
  
  <blockquote>
    <p>Cannot find drive. A drive with the name 'IIS' does not exist.</p>
  </blockquote>
  
  <pre><code>Invoke-Command -ComputerName RMMachine -ScriptBlock {
      Get-ItemProperty 'IIS:\Sites\Default Web Site\CIDashboard' -Name physicalPath
  }
  </code></pre>
  
  <p>and if I make a script file with that command, that fails with the same error</p>
  
  <pre><code>Invoke-Command -ComputerName RMMachine -FilePath 'C:\PowerShell\GetSetIISPath.ps1'
  </code></pre>
  
  <p>As a long-shot, I tried <code>Import-WebAdministration</code> locally but no luck. Note that <code>Copy-Item</code> to that machine from mine works great ruling out any connection issues.</p>
  
  <p>I am running PowerShell in Admin mode on both local and remote machines.</p>
  
  <p><strong>Further observation</strong> - I tried to execute the same command after doing a <code>Enter-PSSession RMMACHINE</code> and I am getting the same error! This means that the <code>Get-ItemProperty</code> works only if physically typed at the terminal on that machine. So, what authentication config am I missing? Note that I am logged in as the same AD user on both machines.</p>