Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created March 13, 2015 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/484eb67652b3c928940d to your computer and use it in GitHub Desktop.
Save wpsmith/484eb67652b3c928940d to your computer and use it in GitHub Desktop.
PowerShell: Add MIME type to SharePoint
function Add-SPAllowedInlineDownloadedMimeType{
[CmdLetBinding()]
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeLine=$true)]
[Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]$WebApplication,
[Parameter(Mandatory=$true, Position=1)]
[string]$MimeType
)
process{
$actualWebApp = $WebApplication.Read()
if ($actualWebApp.AllowedInlineDownloadedMimeTypes -notcontains $mimetype)
{
Write-Host "Adding MIME Type..."
$actualWebApp.AllowedInlineDownloadedMimeTypes.Add($mimetype)
$actualWebApp.Update()
Write-Host "Done."
} Else {
Write-Host -ForegroundColor Green "MIME type is already added."
}
}
}
Add-SPAllowedInlineDownloadedMimeType -WebApplication http://mywebapp -MimeType "text/html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment