Find the http response headers for IIS using powershell

Viewed 620

I want to find the custom headers for a particular site.

I am able to view the raw attributes using the below command. I think this is global value for all sites. I have created some headers for some sites. But I am not able to view it. Is there a command to view for a particular site.

>Get-IISConfigSection -SectionPath system.webServer/httpProtocol | Get-IISConfigCollection -CollectionName "customHeaders"

Attributes      : {name, value}
ChildElements   : {}
ElementTagName  : add
IsLocallyStored : True
Methods         : 
RawAttributes   : {[name, X-Powered-By], [value, ASP.NET]}
Schema          : Microsoft.Web.Administration.ConfigurationElementSchema

UPDATE
I was able to find using the below command.

> Get-IISConfigSection -SectionPath system.webServer/httpProtocol -CommitPath "testsite" | Get-IISConfigCollection -CollectionName "customHeaders"

But I am not able to extract the name and value. I used select-object rawattribute, but it gives empty {}

1 Answers

You can use the Get-Website command to get the configuration information of a specific website:

Get-Website -Name "Default Web Site"

This command will return the configuration information of the default website.

Related