Set-IisHttpHeader

Sets an HTTP header for a website or a directory under a website.

Syntax

Set-IisHttpHeader [-SiteName] <String> [[-VirtualPath] <String>] [-Name] <String> [-Value] <String> [-WhatIf] [-Confirm] [<CommonParameters>]

Description

If the HTTP header doesn't exist, it is created. If a header exists, its value is replaced.

Beginning with Carbon 2.0.1, this function is available only if IIS is installed.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
SiteName String

The name of the website where the HTTP header should be set/created.

true false
VirtualPath String

The optional path under SiteName where the HTTP header should be set/created.

false false
Name String

The name of the HTTP header.

true false
Value String

The value of the HTTP header.

true false
WhatIf SwitchParameter false false
Confirm SwitchParameter false false
CommonParameters This cmdlet supports common parameters. For more information type
Get-Help about_CommonParameters.

EXAMPLE 1

Set-IisHttpHeader -SiteName 'SopwithCamel' -Name 'X-Flown-By' -Value 'Snoopy'

Sets or creates the SopwithCamel website's X-Flown-By HTTP header to the value Snoopy.

EXAMPLE 2

Set-IisHttpHeader -SiteName 'SopwithCamel' -VirtualPath 'Engine' -Name 'X-Powered-By' -Value 'Root Beer'

Sets or creates the SopwithCamel website's Engine sub-directory's X-Powered-By HTTP header to the value Root Beer.