2 回答
TA贡献1829条经验 获得超13个赞
例如,尝试添加以下检查:
$path = "/system.webServer/rewrite/allowedServerVariables"
$value = "HTTP_COOKIE"
if ((Get-WebConfiguration $path).Collection.Name -notcontains $value) {
Add-WebConfiguration $path -AtIndex 0 -Value @{ name = $value }
}
TA贡献1775条经验 获得超8个赞
我的答案是使用Get-WebConfigurationProperty。两者都可以工作。
Write-Host "Getting allowed server variables..."
$allowedServerVariables = Get-WebConfigurationProperty -PSPath "MACHINE/WEBROOT/APPHOST" -filter "system.webServer/rewrite/allowedServerVariables/add" -Name name
Write-Host "Found $($allowedServerVariables.Length)..."
if ( ($allowedServerVariables -eq $null) -or ( $allowedServerVariables | ?{ $_.Value -eq "HTTP_COOKIE1" } ).Length -eq 0 ) {
#Configure IIS To Allow 'HTTPS' as a server variable - Must be done at a applicationhosts.config level
Write-Host "Adding HTTPS to allowed server variables..."
Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST" -filter "system.webServer/rewrite/allowedServerVariables" -name "." -value @{name='HTTP_COOKIE1'}
}
Write-Host "Getting allowed server variables...Finished"
- 2 回答
- 0 关注
- 131 浏览
添加回答
举报