catch 重命名的exception [System.Data.DuplicateNameException])

来源:互联网 发布:系统垃圾清理软件排名 编辑:程序博客网 时间:2024/06/06 02:54

try{Enable-SPFeature-Identity<FEATURE>-Url <SCOPE>-ErrorActionStop}

catch[System.Management.Automation.ActionPreferenceStopException]

{   

       if(!($_.Exception-is [System.Data.DuplicateNameException]))   

                {       #Its not a "feature is already activated at scope" exception       throw        }   

     else   {        #Handle the "feature is already activated at scope" exception   }

}