Search code examples
powershelliismime

Powershell Check MIME exists in IIS


I've got the following command to add a MIME type to IIS using PowerShell

add-webconfigurationproperty //staticContent -name collection -value @{fileExtension='.xpa'; mimeType='application/octet-stream'} 

How can I check if the MIME type exists first before invoking add-webconfigurationproperty?


Solution

  • You can check with the following:

    if( !((Get-WebConfiguration //staticcontent).collection | ? {$_.fileextension -eq '.xpa'}) ) {
      #do something
    }