简体   繁体   中英

Find the http response headers for IIS using powershell

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 {}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM