【问题标题】:Powershell Check MIME exists in IISPowershell 检查 MIME 是否存在于 IIS 中
【发布时间】:2015-04-10 11:24:03
【问题描述】:

我有以下命令使用PowerShellMIME类型添加到IIS

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

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

【问题讨论】:

    标签: powershell iis mime


    【解决方案1】:

    您可以通过以下方式进行检查:

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

    【讨论】:

      【解决方案2】:

      您还可以使用以下方法检查“属性”是否存在:

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

      【讨论】:

        猜你喜欢
        • 2020-02-02
        • 1970-01-01
        • 2017-11-11
        • 2017-09-24
        • 2015-10-31
        • 2018-10-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多