Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote WMI into IIS7

Status
Not open for further replies.

ajtsystems

IS-IT--Management
Jan 15, 2009
80
GB
Hi,

I've been trying to remotely query using WMI an instance of IIS7. I've ritten the code which includes all the username and password but I am getting access denied.

Const strInFile = "hostlist.txt"
Const strOutFIle = "results.txt"
Const ForReading = 1

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objInFile, objOutFile
Set objInFile = objFSO.OpenTextFile(strInFile,ForReading, False)



Do Until objInFile.AtEndOfStream
strComputer = "james-pc"
strDomain = "DOMAIN"
strUser = "james"
strpassword= "jamesjames1"
strComputer = objInFile.Readline

wscript.echo strcomputer
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer (strComputer, "root\WebAdministration", "james", "jamesjames1", ms406)
objSWbemServices.Security_.ImpersonationLevel = 3
Set colitems = objSWbemServices.ExecQuery("Select * From Application")


for each objapp in colitems
wscript.echo objapp.sitename
wscript.echo objapp.path
next
Loop

Looking into it I think I need to add into the WMI objSWbemLocator.ConnectServer a packet privacy string but can't seem to find any other information. Help would be good....
 
A couple comments which may or may not be helpful.

Checkout MSDN explaination. Concerning this particular instance, a permission denied indicates incorrect credentials.

It also states that WMI must be installed on the remote machine. A script was posted the other day to do this Or enable an already installed WMI
It's common to use ImpersonationLevels when connecting to remote WMI objects. However, as eluded to in the aforementioned comment, it may not be possible in this particular instance. MSDN says "The server process can impersonate the client's security context on its local system. The server cannot impersonate the client on remote systems."
Try removing the impersonation.

I hope it helps.

-Geates


"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top