Running IIS command on remote server via Powershell
- by Paul Hunt
I am trying to check if an IIS application pool exists on a remote server using a PowerShell script. The command I am running is:
test-path "IIS:\AppPools\DefaultAppPool"
If I run this script directly on the IIS server in question I get a response back of "True" so this tells me that I have IIS management correctly configure in PowerShell. However when I run the following script from a remote server I get a response of "False"
invoke-command -ComputerName IISSERVER -ScriptBlock { test-path "IIS:\AppPools\DefaultAppPool" }
I know that PowerShell remoting is correctly configured because I can run the following command and get a list of files
invoke-command -ComputerName IISSERVER -ScriptBlock { get-childitems "c:\" }
So why am I getting the wrong response about the existence of the application pool?