Enabling Mime types using PowerShell Script

Enabling Mime types using PowerShell Script

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null  
$oContentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;  
[Microsoft.SharePoint.Administration.SPWebApplicationCollection]$waColl = $oContentService.WebApplications;  
$waColl1 = $waColl | where-object {$_.IsAdministrationWebApplication -eq $FALSE}  
foreach ($wa in $waColl1)  
{  
                write-host "Web application " $wa.DisplayName
                $mimetype = "application/pdf"
                If ($wa.AllowedInlineDownloadedMimeTypes -notcontains $mimetype) 
                {
                                $wa.AllowedInlineDownloadedMimeTypes.Add($mimetype)
                                $wa.Update()
                                Write-Host -ForegroundColor Yellow "Added MIME type " $mimetype
                }
                Else
                {
                                Write-Host -ForegroundColor Green "MIME type " $mimetype " is already added."
                } 
                $mimetype = "application/vnd.ms-outlook"
                If ($wa.AllowedInlineDownloadedMimeTypes -notcontains $mimetype) 
                {
                                $wa.AllowedInlineDownloadedMimeTypes.Add($mimetype)
                                $wa.Update()
                                Write-Host -ForegroundColor Yellow "Added MIME type " $mimetype
                }
                Else
                {
                                Write-Host -ForegroundColor Green "MIME type " $mimetype " is already added."
                } 
}  
write-host "Finished."
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s