1.

Solve : Talking to IIS 7 (Windows 7, 2008)?

Answer»

Hi,

I got the following script from the windows scripting book for windows 2003 so obviously written for IIS 6.

The rror I am getting when I run this is :

iis.vbs(13, 1) (null): 0x8004100E

This is - Syntax error.

Line 13 is - Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & wmiNS)


I THINK the problem is what I am passing on wmiNS.

I TRIED different values based on several articles I have read after a few google searches.

- GetObject("IIS://" & ComputerName & "/W3SVC")
- GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "/W3SVC")
- wmiNS = “/root/MicrosoftIISv2"

Nothing worked. I am not ABLE to find any thing. Can you please LET me know what am i doing wrong and also point me to a book/site/tutorial on using scripts on IIS 7? (MAINLY to create Application Pools, set application pool parameters, Create sites, create site specific parameters, create site specific ASP paramters, etc)

Thanks for your time

Code: [Select]Option Explicit
'On Error Resume Next
Dim strComputer
Dim wmiNS
Dim wmiQuery
Dim objWMIService
Dim colItems
Dim objItem

strComputer = "."
wmiNS = "\root\WebAdministration"
wmiQuery = "select * from CIM_Setting"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & wmiNS)

Set colItems = objWMIService.ExecQuery(wmiQuery)
For Each objItem In colItems
WScript.Echo ": " & objItem.Name
Next

Thanks,
Shiyam



Discussion

No Comment Found