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
?
You can check with the following:
if( !((Get-WebConfiguration //staticcontent).collection | ? {$_.fileextension -eq '.xpa'}) ) {
#do something
}
You can also check for the existence of a 'property' using this:
if (!(Get-WebConfigurationProperty //staticContent -Name collection[fileExtension=".xpa"]))
{
Write-Host ".xpa doesn't exist"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With