Error Adding PDF MIME type and suggested fix.

Nov 2, 2011 at 4:40 PM

Although this is pretty minor I thought I'd post it. My install using a port other than :80 finally ran successfully with one exception.
- Adding PDF MIME type "application/pdf" web apps... Get-SPWebApplication : Cannot find an SPWebApplication object with Name, Id, or Url: http://MEM-QA-SP-01. At C:\SP2010\AutoSPInstaller\AutoSPInstallerFunctions.ps1:3782

I am far from a powershell pro, but I determined that the "Configure-PDFSearchAndIcon" function had not accounted for my web port when looking for the application.
Here is my proposed fix with the old code commented out:
Write-Host -ForegroundColor White " - Adding PDF MIME type `"$MimeType`" web apps..." 
ForEach ($WebAppConfig in $xmlinput.Configuration.WebApplications.WebApplication)
{ 
    #$webApp = Get-SPWebApplication $($WebAppConfig.url) 
    #hopefully fix bug where url contains a port 
    $webApp = Get-SPWebApplication | Where-Object {$_.DisplayName -eq $WebAppConfig.Name}
    If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains $MimeType) 
    {
        #hopefully fix bug where url contains a port 
        Write-Host -ForegroundColor White " - $($webApp.Url): Adding..." -NoNewline
        #Write-Host -ForegroundColor White " - $($WebAppConfig.url): Adding..." -NoNewline
         $webApp.AllowedInlineDownloadedMimeTypes.Add($MimeType) $webApp.Update()
        Write-Host -ForegroundColor White "Done." 
    }
    Else
    {
        #hopefully fix bug where url contains a port 
        Write-Host -ForegroundColor White " - $($webApp.Url): Already added." 
        #Write-Host -ForegroundColor White " - $($WebAppConfig.url): Already added."
    }
}
Write-Host -ForegroundColor White " - Restarting IIS..."
Hope that helps someone. or suggests a better way.
Coordinator
Nov 2, 2011 at 4:48 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.