IIS 配置修改 'maximum content length' 使用电源 shell
IIS configuration to modify 'maximum content length' using power shell
我正在尝试将 "maximum content length" 的值配置为“30000000”(约 28.6 MB)。我的脚本如下-
cd C:\Windows\System32\inetsrv
./appcmd set config /section:requestfiltering /requestlimits.maxallowedcontentlength:30000000
If ((Get-WindowsFeature Web-Filtering).Installed -EQ $true) {
Get-Website | Foreach-Object {
$site = $_
[PSCustomObject]@{
"Site" = $site.Name
"maxAllowedContentLength" = (((Get-WebConfiguration -Filter 'system.webServer/security/requestFiltering' -PSPath "IIS:\sites$($site.Name)").requestLimits).Attributes | Where-Object Name -EQ 'maxAllowedContentLength').Value
}
}
}
脚本成功执行,但当我检查 'Internet Service Manager' 时,没有反映任何变化。我想知道脚本中有什么错误吗?因为它returns没有错误可以排除。
这帮助我找到了解决方案:
./appcmd 设置配置 "WebsiteName "/section:requestfiltering /requestlimits.maxallowedcontentlength:30000000 /commit:site
我正在尝试将 "maximum content length" 的值配置为“30000000”(约 28.6 MB)。我的脚本如下-
cd C:\Windows\System32\inetsrv
./appcmd set config /section:requestfiltering /requestlimits.maxallowedcontentlength:30000000
If ((Get-WindowsFeature Web-Filtering).Installed -EQ $true) {
Get-Website | Foreach-Object {
$site = $_
[PSCustomObject]@{
"Site" = $site.Name
"maxAllowedContentLength" = (((Get-WebConfiguration -Filter 'system.webServer/security/requestFiltering' -PSPath "IIS:\sites$($site.Name)").requestLimits).Attributes | Where-Object Name -EQ 'maxAllowedContentLength').Value
}
}
}
脚本成功执行,但当我检查 'Internet Service Manager' 时,没有反映任何变化。我想知道脚本中有什么错误吗?因为它returns没有错误可以排除。
这帮助我找到了解决方案: ./appcmd 设置配置 "WebsiteName "/section:requestfiltering /requestlimits.maxallowedcontentlength:30000000 /commit:site