How can I program global MIME types for IIS6?

I can currently set the mime type with adsutil.vbs for the main website in IIS6 with the following syntax:

cscript adsutil.vbs set W3SVC/1/Root/MimeMap ".manifest, text/cache-manifest" 

This seems like normal when I only need to configure W3SVC / 1.

I need to write an update script to ensure that the appropriate mime type is configured on any sites on this IIS6 installation. I could either add the mime type to each individual site, or globally. I have to do this programmatically and would like to use adsutil.vbs, if at all possible.

+4
source share
2 answers

I think it will be easier to just change the mime types on each server, you only need to do it once so that the changes are cascaded to each website, why are you trying to rewrite the MIME.vbs type? you might be better off creating a custom one.

Or you can set the change in the metabase for IIS, you just need to set the correct conversion of the direct metabase to true on each server, and then make the changes, although the code is.

0
source

You can use ADSI and powershell 2.0.

 $adsiPrefix = "IIS://$serverName" $iisPath = "W3SVC" $iisADSI = [ADSI]"$adsiPrefix/$iisPath" $site = $iisADSI.Create("IISWebServer", $script:webSiteNumber) $xapMimeType = New-Object -comObject MimeMap SetCOMProperty $xapMimeType "Extension" ".xap" SetCOMProperty $xapMimeType "MimeType" "application/x-silverlight-app" $site.Properties["MimeMap"].Add($xapMimeType) $site.SetInfo() $site.CommitChanges() function SetCOMProperty($target, $member, $value) { $target.psbase.GetType().InvokeMember($member, [System.Reflection.BindingFlags]::SetProperty, $null, $target, $value) } 
0
source

All Articles