[英]Powershell returns null instead of an exception when accessing COM property that fails
[英]Powershell script returns exception when using ADSI
在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提供程序,並且我已啟用它,仍然有此異常...
你只嘗試一個參數嗎?
$iisMgr.psbase.children.find("MyVirtualDir")
我不知道那里,但是當我調用一個參數數量不好的方法時,我遇到了這種COM錯誤。
J.P
只是一些想法:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.