janikvonrotz
6/25/2013 - 11:27 AM

PowerShell: Set Browser File Handling For SharePoint Webapplication #PowerShell #SharePoint

PowerShell: Set Browser File Handling For SharePoint Webapplication #PowerShell #SharePoint

# get all webapplications
$SPWebApps = Get-SPWebApplication

# set global file handling
$SPWebApps | foreach-object {
 if($_.BrowserFileHandling -ne "strict" ){
      $_.BrowserFileHandling = "strict" 
      $_.Update()
  }
}
# get all webapplications
$SPWebApps = Get-SPWebApplication

# set browser mime type
$mimeType = "application/pdf"
$SPWebApps | foreach-object {

  # If the MIME Type is on the allowed list for the Web Application 
  if($_.AllowedInlineDownloadedMimeTypes.Contains($mimeType)){
  
    # Remove the MIME type from the allowed list and update the Web Application 
    $_.AllowedInlineDownloadedMimeTypes.Remove($mimeType) | Out-Null 
    $_.Update() 
    Write-Host Removed $mimeType from the allowed list of Web Application $_.Name 
  
  }else{ 
  
    # The MIME type was not on the list - can't remove. Inform user 
    Write-Host Skipped Web Application $_.Name - $mimeType was not on the allowed list 
  } 
} 
# get all webapplications
$SPWebApps = Get-SPWebApplication

# set browser mime type
$mimeType = "application/pdf"
$SPWebApps | foreach-object { 

    # If the MIME Type is not already on the allowed list for the Web Application 
    if(!$_.AllowedInlineDownloadedMimeTypes.Contains($mimeType)){ 

        # Add the MIME type to the allowed list and update the Web Application 
        $_.AllowedInlineDownloadedMimeTypes.Add($mimeType) 
        $_.Update() 
        Write-Host Added $mimeType to the allowed list for Web Application $_.Name 

    }else{ 

        # The MIME type was already allowed - can't add. Inform user 
        Write-Host Skipped Web Application $_.Name - $mimeType was already allowed 
    } 
}