ajtsystems
IS-IT--Management
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....
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....