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 關注
- 162 瀏覽
添加回答
舉報