sqlagent007
asked on
How to automate or script the configuration of IIS 7.5 REQUEST FILTERING for a site
How can I script the "Request Filtering" in IIS 7.5?
I would like a way to ensure that the file extensions are all the same across all 4 of our IIS servers. The way I do this manually now is:
* Open IIS manager
* Select the site
* find the "Request Filtering" icon
* Click "open feature"
Once I am in the feature, I can remove extensions and add them. How can I create a script that will allow me to push these settings to all 4 of my web servers to make sure they stay the same across all servers all the time. I have attached a screen with the extensions screen I am speaking of. I have all the extensions in a text file. I just need a pointer to a good web article or powershell command that would allow me to manage this via script not GUI.
Thanks experts!
IIS-request-filter-extensions.jpeg
I would like a way to ensure that the file extensions are all the same across all 4 of our IIS servers. The way I do this manually now is:
* Open IIS manager
* Select the site
* find the "Request Filtering" icon
* Click "open feature"
Once I am in the feature, I can remove extensions and add them. How can I create a script that will allow me to push these settings to all 4 of my web servers to make sure they stay the same across all servers all the time. I have attached a screen with the extensions screen I am speaking of. I have all the extensions in a text file. I just need a pointer to a good web article or powershell command that would allow me to manage this via script not GUI.
Thanks experts!
IIS-request-filter-extensions.jpeg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hmmm. I don't have WebAdministration on my IIS 7.5 server. Perhaps because I did a B2B upgrade to get there? I dunno, it's too old a version of OS to worry much about. But it appears to just be a wrapper around appcmd.
Went deep down into the dusty archives and tested on a plain Server 2008 R2 with PS 2.0 (actually has PS 3.0 installed, but the module works in 2.0 as well); no additional PS modules installed.
PS C:\> (gwmi Win32_OperatingSystem).Version
6.1.7601
PS C:\> $PSVersionTable.PSVersion.ToString()
2.0
PS C:\> (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\InetStp).VersionString
Version 7.5
PS C:\> ipmo WebAdministration -PassThru | fl
Name : WebAdministration
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\WebAdministration\WebAdministration.psd1
Description :
ModuleType : Manifest
Version : 1.0.0.0
NestedModules : {Microsoft.IIS.PowerShell.Provider}
ExportedFunctions : IIS:
ExportedCmdlets : {Add-WebConfiguration, Add-WebConfigurationLock, Add-WebConfigurationProperty, Backup-WebConfiguration...}
ExportedVariables : {}
ExportedAliases : {Begin-WebCommitDelay, End-WebCommitDelay}
PS C:\> Get-WebConfiguration -PSPath 'IIS:\Sites\Default Web Site' -Filter 'system.webserver/security/requestFiltering/fileExtensions'
allowUnlisted : True
applyToWebDAV : True
Collection : {Microsoft.IIs.PowerShell.Framework.ConfigurationElement, Microsoft.IIs.PowerShell.Framework.Co
nfigurationElement, Microsoft.IIs.PowerShell.Framework.ConfigurationElement, Microsoft.IIs.Powe
rShell.Framework.ConfigurationElement...}
PSPath : MACHINE/WEBROOT/APPHOST/Default Web Site
Location :
ConfigurationPathType : Location
ItemXPath : /system.webServer/security/requestFiltering/fileExtensions
Attributes : {allowUnlisted, applyToWebDAV}
ChildElements : {}
ElementTagName : fileExtensions
Methods :
Schema : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema
I believed you. :-)
For my own peace of mind
ASKER
Hoping I can split points here, both of you have been so helpful! Thank you! I ended up using appcmd.exe as that seems to work across all W2008 servers (yes, the are being donated to a museum). However I am rapidly trying to lear PoSh, so the input from oBdA was also very helpful. Thanks again!
In your case, for a defined set of allowed extensions, you'd use Set-, which eradicates everything that was there before.
All you need is the PSPath to the site and the list of extensions:
Open in new window