簡體   English   中英

使用ADSI時,Powershell腳本會返回異常

[英]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

只是一些想法:

  • 在進行ADSI交互時,您是否進行了身份驗證?
  • 根據你的$ vDirPath示例,我猜你沒有使用全局目錄。 在任何情況下都可以查看如何修改復制到全局編錄的屬性
  • 嘗試使用提升的用戶權限運行Powershell會話(右鍵單擊以管理員身份運行)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM