Running IIS command on remote server via Powershell

Posted by Paul Hunt on Super User See other posts from Super User or by Paul Hunt
Published on 2013-06-19T16:17:54Z Indexed on 2013/06/27 10:24 UTC
Read the original article Hit count: 337

Filed under:
|

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?

© Super User or respective owner

Related posts about powershell

Related posts about iis