Powershell Get-WebSite name parameter is ignored
According to this forum post, this is a bug in the Get-Website cmdlet. The workaround until this is addressed is to use Get-Item.
$website = "Test"Get-Item "IIS:\sites\$website"
Be sure to use double quotes, variables are not expanded when single quotes are used.
I realize it's an older post but I ran into this issue recently and found your question. I've had luck with the following syntax too:
get-website | where { $_.Name -eq 'foobar' }
Using wild cards will also get around this issue as mentioned in the work around in the connect topic referenced by @Joey
get-website -name "*Default Web Site*"