6
3
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?
1note that in the example for invoke-command, get-childitems "c:" should read get-childitem "c:". That will teach me to copy and paste. – rob – 2014-01-15T10:22:37.177