Xanderu
Xanderu

Reputation: 787

Powershell to set DefaultSite's asp limits

I have been trying to build a powershell script to build the app pools and setup the correct limits in IIS to avoid doing it manually, but I cannot figure out how to adjust the Maximum Requesting Entity body limit in the default site's ASP limit properties. I've found some CMD examples to do this:

appcmd set config /section:asp /maxRequestEntityAllowed: int

but I do not have appcmd and I'd really rather do this exclusively with powershell as I've been able to create and update the other IIS settings using the webadministration module EX

[string]$Account = $cred.UserName
[string]$AccountPW = $cred.Password | ConvertFrom-SecureString

If(!(Get-Module WebAdministation))
{
    import-module WebAdministration
}

$iisAppPoolPath = "IIS:\AppPools\TEST"

$oappPool = New-Item $iisAppPoolPath 
$oappPool | Set-ItemProperty -name "enable32BitAppOnWin64" -Value "true"
$oappPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value "v4.0"
$oappPool | Set-ItemProperty -Name "managedPipelineMode" -Value "Classic"
$oappPool | Set-ItemProperty -name "processModel" -value @{userName=$Account;password=$AccountPW;identitytype=3}

I've been reading through a bunch of different articles and references but I cannot seem to figure this part out. I can get the default site but I'm not exactly sure which element I need to set to be able to update the value

Get-Item 'IIS:\Sites\Default Web Site\'

Any suggestions would be greatly appreciated

I've also tried this but it doesn't work

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

reference: http://www.zerrouki.com/classic-asp-upload-file-fails-200kb/

Upvotes: 1

Views: 1821

Answers (2)

Chuck D
Chuck D

Reputation: 1819

Something like this might work to set all sites:

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

Upvotes: 0

Xanderu
Xanderu

Reputation: 787

I figured it out. It doesn't use the set-item function but it work:

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

The location param and the " marks made the difference

Upvotes: 2

Related Questions