2015-02-10 55 views
2
存在

我有以下命令将MIME类型添加到IIS使用PowerShellPowerShell的检查MIME在IIS

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

我如何检查是否MIME类型调用add-webconfigurationproperty之前首先存在?

回答

4

您可以用下面的检查:

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

您还可以查看是否有“财产”的存在,使用此:

if (!(Get-WebConfigurationProperty //staticContent -Name collection[fileExtension=".xpa"])) 
{ 
    Write-Host ".xpa doesn't exist" 
}