Asp.net Powershell设置DefaultSite';s asp限制

Asp.net Powershell设置DefaultSite';s asp限制,asp.net,powershell,iis,Asp.net,Powershell,Iis,我一直在尝试构建powershell脚本来构建应用程序池,并在IIS中设置正确的限制,以避免手动执行此操作,但我不知道如何在默认站点的ASP限制属性中调整最大请求实体体限制。我发现了一些CMD示例可以做到这一点: appcmd set config /section:asp /maxRequestEntityAllowed: int 但是我没有appcmd,我真的更愿意只使用powershell,因为我已经能够使用webadministration模块创建和更新其他IIS设置 前 我读了很多不

我一直在尝试构建powershell脚本来构建应用程序池,并在IIS中设置正确的限制,以避免手动执行此操作,但我不知道如何在默认站点的ASP限制属性中调整最大请求实体体限制。我发现了一些CMD示例可以做到这一点:

appcmd set config /section:asp /maxRequestEntityAllowed: int
但是我没有appcmd,我真的更愿意只使用powershell,因为我已经能够使用webadministration模块创建和更新其他IIS设置 前

我读了很多不同的文章和参考文献,但我似乎无法理解这一部分。我可以获得默认站点,但我不确定需要设置哪个元素才能更新该值

Get-Item 'IIS:\Sites\Default Web Site\'
如有任何建议,将不胜感激

我也试过这个,但不起作用

Set-WebConfigurationProperty /system.webserver/asp/limits -name maxRequestEntityAllowed -value "10485760"

参考资料:

我想出来了。它不使用set item函数,但可以工作:

cd IIS:\Sites\
set-WebConfigurationProperty -location 'Default Web Site' -filter "system.webServer/asp/limits" -name "maxRequestEntityAllowed" -value 123456789

location参数和“marks”产生了差异

类似的内容可能适用于设置所有站点:

Import-Module "WebAdministration"
Get-ChildItem IIS:\Sites | select -expand Name | % { 
    Set-WebConfigurationProperty -Location $_ -Filter "system.webServer/asp/limits" -Name "maxRequestEntityAllowed" -Value 40000000
}

请尝试
$oappPool | GM-Force
并查看是否可以找到您要查找的属性。当我运行Get Item“IIS:\Sites\Default Web Site\”时| GM-Force我确实看到了Limits属性,但最大限制是子属性,仅添加\Limits不起作用。我知道我打错了电话,但我不是IIS人,所以我真的不知道正确的方法要调用itSo,请尝试
(获取项目“IIS:\Sites\Default Web Site\”).Limits | GM-Force
,直到您找到要编辑的属性。这不是我的知识领域,但PS在整个过程中都非常相似。我尝试过,但我能看到的唯一noteproperties是connectionTimeout、maxBandwidth、maxConnections、maxUrlSegments。我确信它嵌套在其他内容下,这正是我努力想弄清楚的。我很抱歉对maxRequestEntityAllowed进行rching,我在默认站点的任何地方都找不到它,这不是一个真正的答案,但powershell中的
%windir%\system32\inetsrv\appcmd.exe
“${ENV:windir}\system32\inetsrv\appcmd.exe”
Import-Module "WebAdministration"
Get-ChildItem IIS:\Sites | select -expand Name | % { 
    Set-WebConfigurationProperty -Location $_ -Filter "system.webServer/asp/limits" -Name "maxRequestEntityAllowed" -Value 40000000
}