IIS中存在Powershell Check MIME

hey*_*ega 4 iis powershell mime

我有以下命令将添加MIME类型IIS使用PowerShell

add-webconfigurationproperty //staticContent -name collection -value @{fileExtension='.xpa'; mimeType='application/octet-stream'} 
Run Code Online (Sandbox Code Playgroud)

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

arc*_*444 6

您可以检查以下内容:

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