开发者

Powershell Get-WebSite name parameter is ignored

I want to retrieve information regarding specific IIS 7 website using the PowerShell Get-Website cmdlet. Unfortunately, Get-Website returns information for all websites regardless of the -Name parameter I pass in. It appears that the -Name parameter is ignored.

For instance, if I use:

Import-Module WebAdministration
Get-开发者_运维知识库Website -Name "Test Website"

I will receive information for all websites on my machine:

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:
                                                                net.tcp 808:*
                                                                net.pipe *
                                                                net.msmq localhost
                                                                msmq.formatname localhost
Test Website     2    Started    C:\websites\test               http *:80:test.mydomain.com

According to the documentation Get-Website should return information for the website specified in the -Name parameter. I must be misunderstanding the documentation or misusing the cmdlet, or both.

How should I use Get-Website to return information for a specific website?


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*"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜