Jump to content

IIS Get sites Object


lrstndm
 Share

Recommended Posts

I just started using object using autoit, I want to get some information from IIS.

Searching the internet I found this piece of code in VBScript

Set oIIS = GetObject("winmgmts:rootWebAdministration")
Set oSite = oIIS.Get("Site.Name='Default Web Site'")
WScript.Echo "Retrieved an instance of Site "
WScript.Echo " Name: " & oSite.Name
WScript.Echo " ID: " & oSite.ID

 

 

Trying to convert the code and searching the forum I made this piece of code....

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")    ; Initialize a COM error handler

$oIIS = ObjGet("winmgmts:root\WebAdministration")
$oSite = $oIIS.Get("Site.Name='Default Web Site'")
MsgBox(0, '', $oSite.Name & Chr(13) & $oSite.ID)

Exit

Func MyErrFunc()
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"   & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description  & @CRLF & _
             "err.windescription:"  & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "      & @TAB & hex($oMyError.number,8)  & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "  & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "      & @TAB & $oMyError.source       & @CRLF & _
             "err.helpfile is: "      & @TAB & $oMyError.helpfile     & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
Endfunc

When running the code I got some exception while getting the objects, what am I doing wrong?

Regards,

lrstndm

 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...