Unable to open PDF/HTML/XML files directly in
browser in SharePoint 2010? Default configuration of SharePoint 2010
does not consider PDF documents safe for displaying in the browser.This
script adds new MIME type to "AllowedInlineDownloadedMimeTypes" property
list of defined SharePoint 2010 Web Application.
If ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } Get-SPWebApplication $WebApp = Get-SPWebApplication $(Read-Host "`nEnter Web Application URL") Write-Host `n"Mime Type Examples:"`n"application/pdf, text/html, text/xml"`n If ($WebApp.AllowedInlineDownloadedMimeTypes -notcontains ($MimeType = Read-Host "Enter a required mime type")) { Write-Host -ForegroundColor White `n"Adding" $MimeType "MIME Type to defined Web Application"$WebApp.url $WebApp.AllowedInlineDownloadedMimeTypes.Add($MimeType) $WebApp.Update() Write-Host -ForegroundColor Green `n"The" $MimeType "MIME type has been successfully added." } Else { Write-Host -ForegroundColor Red `n"The" $MimeType "MIME type has already been added." }
Ref:
http://gallery.technet.microsoft.com/scriptcenter/Add-new-MIME-type-open-PDF-f6c57c32
No comments:
Post a Comment