Powershell script returns an exception when using ADSI

I get exceptions when running the Power script shell (v1.0) on Windows Server 2008 (32 bit).

It uses ADSI to search for a virtual directory before deleting it.

I get the following exception:

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

This is the code:

$vDirPath = "IIS://localhost/W3SVC/1/Root"
$iisMgr = [adsi]$vDirPath
$iisMgr.psbase.children.find("MyVirtualDir", $iisMgr.psbase.SchemaClassName)

(edit): from several blogs, I read that the IIS6 compatibility role service must be enabled in order to install the ADSI provider, and I already enabled it, still having this exception ...

+3
source share
2 answers

Are you trying to use only one parameter?

$iisMgr.psbase.children.find("MyVirtualDir")

I do not know, but I have such a COM error when I call a method with a poor number of arguments.

In JP

0
source

Just some ideas:

  • ADSI?
  • , $vDirPath. . ,
  • Powershell ( " " )
0

All Articles