Invalid Namespace Error

R

Randy Snyder

I got the script below off of the Internet. I found it in several places
so it looks to be used widely. When I try to run it, I get an invalid
namespace error. I'm executing the script on Windows XP Pro with Service
Pack 2 and have all current Microsoft patch to date. Any ideas?

strTargetSnmpDevice = "127.0.0.1"

Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWmiServices = objWmiLocator.ConnectServer("", "root\snmp\localhost")

Set objWmiNamedValueSet = CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName", "public"

Set colTcpConnTable = _
objWmiServices.InstancesOf("SNMP_RFC1213_MIB_tcpConnTable", , _
objWmiNamedValueSet)

Set colUdpTable = _
objWmiServices.InstancesOf("SNMP_RFC1213_MIB_udpTable", , _
objWmiNamedValueSet)


WScript.Echo "TCP Connections and Listening Ports" & vbCrLf & _
"-----------------------------------"

For Each objTcpConn In colTcpConnTable
WScript.Echo objTcpConn.tcpConnLocalAddress & ":" & _
objTcpConn.tcpConnLocalPort & " => " & _
objTcpConn.tcpConnRemAddress & ":" & _
objTcpConn.tcpConnRemPort & " " & _
"[State: " & objTcpConn.tcpConnState & "]"
Next

WScript.Echo vbCrLf & "UDP Ports" & vbCrLf & "---------"

For Each objUdp In colUdpTable
WScript.Echo objUdp.udpLocalAddress & ":" & objUdp.UdpLocalPort
Next
 
J

Jonathan Liu [MSFT]

You will need to install the SNMP Provider:

1. Go to the Add/Remove Programs
2. Then go into Add/Remove Windows Components
3. Select Management and Montoring Tools
4. You can click detals to see what you are installing.
5. You will need the SNMP protocol and the Provider.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top