When I tested this on the remote machine directly, it works perfectly.
Get-ItemProperty 'IIS:\Sites\Default Web Site\MySite' -Name physicalPath
However, when I try using the Invoke-Command syntax from my machine, it fails with
Cannot find drive. A drive with the name 'IIS' does not exist.
Invoke-Command -ComputerName RMMachine -ScriptBlock {
Get-ItemProperty 'IIS:\Sites\Default Web Site\CIDashboard' -Name physicalPath
}
and if I make a script file with that command, that fails with the same error
Invoke-Command -ComputerName RMMachine -FilePath 'C:\PowerShell\GetSetIISPath.ps1'
As a long-shot, I tried Import-WebAdministration
locally but no luck. Note that Copy-Item
to that machine from mine works great ruling out any connection issues.
I am running PowerShell in Admin mode on both local and remote machines.
Further observation - I tried to execute the same command after doing a Enter-PSSession RMMACHINE
and I am getting the same error! This means that the Get-ItemProperty
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.