【发布时间】:2019-06-25 02:27:51
【问题描述】:
我正在尝试添加一个新的服务器变量
Add-WebConfiguration /system.webServer/rewrite/allowedServerVariables -atIndex 0 -value @{name="HTTP_COOKIE"}
但我收到以下错误
Add-WebConfigurationProperty : Filename:
Error: Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Test'
At line:1 char:1
+ Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filt ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-WebConfigurationProperty], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.AddConfigurationPropertyCommand
我可以禁止使用 try catch 块,但想检查变量是否已经存在,如果它已经存在则跳过添加。
谁能告诉我如何进行这项检查?
【问题讨论】:
标签: c# asp.net .net windows powershell