Skip to content

Instantly share code, notes, and snippets.

@IAMPetro
Created December 13, 2016 12:35
Show Gist options
  • Save IAMPetro/11faab1a6f1192e17264e4ee5d3dd057 to your computer and use it in GitHub Desktop.
Save IAMPetro/11faab1a6f1192e17264e4ee5d3dd057 to your computer and use it in GitHub Desktop.
SharePoint: Trusted IIS MIME Types
Write-Host "This script will check if a particular MIME Type is excluded from the AllowedInlineDownloadedMimeTypes list when STRICT Browser File Handling Permissions are set on the Web Application" -foregroundcolor Darkcyan
$webAppRequest = Read-Host "What is the name of your Web Application? i.e. http://<serverName>
$webApp = Get-SPWebApplication $webAppRequest
$mimeType = Read-Host "Which MIME Type would you like to confirm is included in the AllowedInlineDownloadedMimeTypes list for $webApp ? i.e. application/pdf"
if ($webApp.AllowedInlineDownloadedMimeTypes -notcontains "$mimeType")
{
write-host "$mimeType does not exist in the AllowedInlineDownloadedMimeTypes list" -foregroundcolor Yellow
$addResponse = Read-Host "Would you like to add it? (Yes/No)"
if ($addResponse -contains "Yes")
{
$webApp.AllowedInlineDownloadedMimeTypes.Add("$mimeType")
$webApp.Update()
Write-Host "The MIME Type ' $mimeType ' has now been added" -foregroundcolor Green
$iisresponse = Read-Host "This change requires an IIS Restart to take affect, do you want to RESET IIS now (Yes/No)"
if ($iisResponse -contains "Yes")
{
IISRESET
Write-Host "IIS has now been reset" -foregroundcolor Green
}
else
{
Write-Host "IIS has not been reset, please execute the IISRESET command at a later time" -foregroundcolor Yellow
}
}
else
{
Write-Host "The MIME Type ' $mimeType ' was not added" -foregroundcolor Red
}
}
else
{
Write-Host "The MIME Type ' $mimeType ' already exists in the AllowedInlineDownloadedMimeTypes list for this Web Application" -foregroundcolor Yellow
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment