Skip to content

Instantly share code, notes, and snippets.

@janikvonrotz
Created June 25, 2013 11:27
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 janikvonrotz/5857772 to your computer and use it in GitHub Desktop.
Save janikvonrotz/5857772 to your computer and use it in GitHub Desktop.
PowerShell: Set Browser File Handling For SharePoint Webapplication #PowerShell #SharePoint
# 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
}
}
# 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 global file handling
$SPWebApps | foreach-object {
if($_.BrowserFileHandling -ne "strict" ){
$_.BrowserFileHandling = "strict"
$_.Update()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment