在 Windows Server 2008(32 位)上执行 Power shell 脚本 (v1.0) 时出现异常。
它使用 ADSI 在删除之前搜索虚拟目录。
我得到以下异常:
Exception calling "Find" with "2" argument(s): "Exception from HRESULT: 0x80005008"
At line:1 char:29
+ $iisMgr.psbase.children.find <<<< ("MyVirtualDir", $iisMgr.psbase.SchemaClassName)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
这是代码:
$vDirPath = "IIS://localhost/W3SVC/1/Root"
$iisMgr = [adsi]$vDirPath
$iisMgr.psbase.children.find("MyVirtualDir", $iisMgr.psbase.SchemaClassName)
(编辑):从几个博客中,我读到必须启用 IIS6 管理兼容性角色服务才能安装 ADSI 提供程序,并且我已经启用了它,仍然有这个异常......