2015-02-10 57 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" 
}