Wednesday, October 3, 2012

IIS ApplicationHost.config - Request Filtering (e.g. Filetype *.mdb)

If you want to allow a filetype like e.g. *.mdb it's not enough to allow that type within SharePoint.
You've to allow it as well within IIS (if request filtering is enabled)

That can be done manually




OR: if you've multiple IIS Servers within your SharePoint Farm via PowerShell Script:


$servers = "server1","server2","server3","server4"
foreach ($server in $servers)
 {
 

 Invoke-Command -computername $server -ScriptBlock {
 
        import-module webadministration
 
        Function Enable-IISFileExtension
        {
            PARAM(
                 $ConfigFile,
                 $FileType,
                 $Flag
        
                 )
            $xml = [XML](Get-Content -Path $ConfigFile -ErrorAction STOP)
            $item = $xml.configuration."system.webServer".security.requestFiltering.fileExtensions.add | Where-Object {$_.fileExtension -match "$FileType"}
            $item.allowed = $Flag
            $xml.Save($ConfigFile)
   
            return $xml.configuration."system.webServer".security.requestFiltering.fileExtensions.add | Where-Object {$_.fileExtension -match "$FileType"}
   
        }
        Enable-IISFileExtension -ConfigFile "C:\Windows\System32\inetsrv\config\applicationHost.config" -FileType ".mdb" -Flag "True"
 
 
  Exit-PSSession
  }
 } 



No comments:

Post a Comment