Jump to content
Sign in to follow this  
lrstndm

IIS Get sites Object

Recommended Posts

lrstndm

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

 

Share this post


Link to post
Share on other sites
Andreik

Put #RequireAdmin at start of your script. For some providers you need adiminstrator rights.

  • Like 1

When the words fail... music speaks

Share this post


Link to post
Share on other sites
lrstndm

Yes you're right. But this won't work for me this time.

Share this post


Link to post
Share on other sites
Andreik

If I run the script above I get this:

 

Default Web Site

1

When the words fail... music speaks

Share this post


Link to post
Share on other sites
lrstndm

Allright....

Do you know what could cause the problem?

I ran it on a Vista 32-bit system and a Windows 7 64-bit system.

Share this post


Link to post
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
Sign in to follow this  

×