PowerShell的检查MIME在IIS
问题描述:
存在
我有以下命令将MIME
类型添加到IIS
使用PowerShell
PowerShell的检查MIME在IIS
add-webconfigurationproperty //staticContent -name collection -value @{fileExtension='.xpa'; mimeType='application/octet-stream'}
我如何检查是否MIME类型调用add-webconfigurationproperty
之前首先存在?
答
您可以用下面的检查:
if(!((Get-WebConfiguration //staticcontent).collection | ? {$_.fileextension -eq '.xpa'})) {
#do something
}
答
您还可以查看是否有“财产”的存在,使用此:
if (!(Get-WebConfigurationProperty //staticContent -Name collection[fileExtension=".xpa"]))
{
Write-Host ".xpa doesn't exist"
}