How to determine if a website is installed in IIS7 with Powershell?
You can use Test-Path for both checking web sites & application pools:
Import-Module webadministration
$alias = "MyWebSite1"
$IISPath = "IIS:\Sites\Default Web Site\$alias"
if (Test-Path $IISPath) { Write-Host "$alias exists." }
$IISPath = "IIS:\AppPools"
cd $IISPath
if (Test-Path ".\MyAppPool") { Write-Host "MyAppPool exists." }
I just noticed the same behavior. Seems like its not working as expected. However, you can roll your own:
get-website | where-object { $_.name -eq 'MyWebsite1' }
That just pipes the list returned by get-website to the where-object cmdlet and just return that single object.
If your new to PowerShell, I can't recommend Master PowerShell enough.