WMI scripts in Mom
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
WMI scripts in Mom

 
Post new topic   Reply to topic    Windows Server Forum Index -> MOM
Author Message
Dave Coate
Guest





Posted: Tue Oct 11, 2005 12:50 am    Post subject: WMI scripts in Mom Reply with quote

Hi All,

I have recently installed Mom 2005 SP1 into our production system and
deployed about 40 agents and the Base OS MP, the DNS MP and the DHCP MP. I
am now working on clearing errors and problems before deploying more. I have
several small issues with only some of the agents. Most of these are with
gathering WMI and Performance Counter data on some, but not all W2K SP4
servers. (the Mom server is W2K3 SP1) For now, I will focus on just one of
the more repeatable errors:

In the Mom Op console I get an error that reads in part, "failed to
execute Mom agent service discovery script"... "the class name
'Win32_OperatingSystem' did not return any valid instances". Now, I know a
fair amount about running scripts that use WMI. I dissected the Mom Agent
Service Discovery script and found the section that throws the error and I
modified the script to run as a WSH script and ran it against the server
that consistently throws the error. The WSH script returns instances just
fine!

So, Mom seems to be installed correctly, as most of my agents are
running this script without any problem. WMI on the problem agent seems to
be operating correctly as I can query it with a WSH script. The problem
agent is one of my remote Domain Controllers (I have 16 DCs in 13
locations). The link to that location is one of our better ones. That is,
there are DCs in locations with less bandwidth and more latency that do not
throw this error. So, netowrk connectivity does not seem to be the issue.
The server with the problem does not have any errors in the event log that I
do not see on other servers and finally, the server is not particularly more
busy than other servers in the system.

I am at a loss to know where to go from here. Does any one have any
ideas?

TIA
Dave Coate

*******************************
Here is the WSH version of the script that I mention above. As stated, this
returns results just fine...

Option Explicit

Dim oOSCollection
Set oOSCollection = WMIGetInstance("winmgmts://" & "<servername>" &
"/root/cimv2", "Win32_OperatingSystem")
Dim oOS, OperatingSystemVersion
For Each oOS In oOSCollection
OperatingSystemVersion = oOS.Caption
Next
Wscript.Echo OperatingSystemVersion

Function WMIGetInstance(ByVal sNamespace, ByVal sInstance)
'
' WMIGetInstance :: Returns WMI Instance requested.
'
'
Dim oWMI, oInstance, nInstanceCount
'Dim e
'Set e = New Error
On Error Resume Next
Set oWMI = GetObject(sNamespace)
'e.Save
On Error Goto 0
If IsEmpty(oWMI) Then
ThrowScriptError "Unable to open WMI Namespace '" & sNamespace & "'.
Check to see if the WMI service is enabled and running, and ensure this WMI
namespace exists.", e
End If

On Error Resume Next
Set oInstance = oWMI.InstancesOf(sInstance)
'e.Save
On Error Goto 0
If err.number <> 0 then Wscript.Echo err.number
If IsEmpty(oInstance) <> 0 Then
ThrowScriptError "The class name '" & sInstance & "' returned no
instances. Please check to see if this is a valid WMI class name.", e
End If

'Determine if we queried a valid WMI class - Count will return 0 or empty

On Error Resume Next
nInstanceCount = oInstance.Count
'e.Save
On Error Goto 0
If err.Number <> 0 Then
ThrowScriptError "The class name '" & sInstance & "' did not return any
valid instances. Please check to see if this is a valid WMI class name.", e
End If

Set WMIGetInstance = oInstance

End Function

Sub ThrowScriptError(str)
Wsctipt.Echo str
End Sub
Back to top
Dave Coate
Guest





Posted: Wed Oct 12, 2005 12:50 am    Post subject: Re: WMI scripts in Mom Reply with quote

Hi again,

I have more information. It turns out that WMI scripts run locally on my
problem server do not work unless I explicitly use
"{impersonationLevel=impersonate}". I believe that is the default. So it
seems that the default on these servers has changed. Does anyone know how to
change the default back? If not, I am going to have to modify all Mom
scripts to explicitly set the impersonationLevel.

Dave


"Dave Coate" <coateds@comcast.net> wrote in message
news:uC4W6JezFHA.2212@TK2MSFTNGP15.phx.gbl...
[quote]Hi All,

I have recently installed Mom 2005 SP1 into our production system and
deployed about 40 agents and the Base OS MP, the DNS MP and the DHCP MP. I
am now working on clearing errors and problems before deploying more. I
have
several small issues with only some of the agents. Most of these are with
gathering WMI and Performance Counter data on some, but not all W2K SP4
servers. (the Mom server is W2K3 SP1) For now, I will focus on just one of
the more repeatable errors:

In the Mom Op console I get an error that reads in part, "failed to
execute Mom agent service discovery script"... "the class name
'Win32_OperatingSystem' did not return any valid instances". Now, I know a
fair amount about running scripts that use WMI. I dissected the Mom Agent
Service Discovery script and found the section that throws the error and I
modified the script to run as a WSH script and ran it against the server
that consistently throws the error. The WSH script returns instances just
fine!

So, Mom seems to be installed correctly, as most of my agents are
running this script without any problem. WMI on the problem agent seems to
be operating correctly as I can query it with a WSH script. The problem
agent is one of my remote Domain Controllers (I have 16 DCs in 13
locations). The link to that location is one of our better ones. That is,
there are DCs in locations with less bandwidth and more latency that do
not
throw this error. So, netowrk connectivity does not seem to be the issue.
The server with the problem does not have any errors in the event log that
I
do not see on other servers and finally, the server is not particularly
more
busy than other servers in the system.

I am at a loss to know where to go from here. Does any one have any
ideas?

TIA
Dave Coate

*******************************
Here is the WSH version of the script that I mention above. As stated,
this
returns results just fine...

Option Explicit

Dim oOSCollection
Set oOSCollection = WMIGetInstance("winmgmts://" & "<servername>" &
"/root/cimv2", "Win32_OperatingSystem")
Dim oOS, OperatingSystemVersion
For Each oOS In oOSCollection
OperatingSystemVersion = oOS.Caption
Next
Wscript.Echo OperatingSystemVersion

Function WMIGetInstance(ByVal sNamespace, ByVal sInstance)
'
' WMIGetInstance :: Returns WMI Instance requested.
'
'
Dim oWMI, oInstance, nInstanceCount
'Dim e
'Set e = New Error
On Error Resume Next
Set oWMI = GetObject(sNamespace)
'e.Save
On Error Goto 0
If IsEmpty(oWMI) Then
ThrowScriptError "Unable to open WMI Namespace '" & sNamespace & "'.
Check to see if the WMI service is enabled and running, and ensure this
WMI
namespace exists.", e
End If

On Error Resume Next
Set oInstance = oWMI.InstancesOf(sInstance)
'e.Save
On Error Goto 0
If err.number <> 0 then Wscript.Echo err.number
If IsEmpty(oInstance) <> 0 Then
ThrowScriptError "The class name '" & sInstance & "' returned no
instances. Please check to see if this is a valid WMI class name.", e
End If

'Determine if we queried a valid WMI class - Count will return 0 or empty

On Error Resume Next
nInstanceCount = oInstance.Count
'e.Save
On Error Goto 0
If err.Number <> 0 Then
ThrowScriptError "The class name '" & sInstance & "' did not return any
valid instances. Please check to see if this is a valid WMI class name.",
e
End If

Set WMIGetInstance = oInstance

End Function

Sub ThrowScriptError(str)
Wsctipt.Echo str
End Sub

[/quote]
Back to top
Dave Coate
Guest





Posted: Wed Oct 12, 2005 8:51 am    Post subject: Re: WMI scripts in Mom Reply with quote

Change the default impersonationLevel -

HKLM\Software\Microsoft\WBEM\scripting

Default Impersonation Level : DWORD : 3

This value was missing on the servers giving me the problem. After adding
the value I restarted the WMI and MOM services on the agent computer and all
is well running scripts that use WMI.


"Dave Coate" <coateds@comcast.net> wrote in message
news:exJfukrzFHA.2880@TK2MSFTNGP12.phx.gbl...
[quote]Hi again,

I have more information. It turns out that WMI scripts run locally on
my
problem server do not work unless I explicitly use
"{impersonationLevel=impersonate}". I believe that is the default. So it
seems that the default on these servers has changed. Does anyone know how
to
change the default back? If not, I am going to have to modify all Mom
scripts to explicitly set the impersonationLevel.

Dave


"Dave Coate" <coateds@comcast.net> wrote in message
news:uC4W6JezFHA.2212@TK2MSFTNGP15.phx.gbl...
Hi All,

I have recently installed Mom 2005 SP1 into our production system
and
deployed about 40 agents and the Base OS MP, the DNS MP and the DHCP MP.
I
am now working on clearing errors and problems before deploying more. I
have
several small issues with only some of the agents. Most of these are
with
gathering WMI and Performance Counter data on some, but not all W2K SP4
servers. (the Mom server is W2K3 SP1) For now, I will focus on just one
of
the more repeatable errors:

In the Mom Op console I get an error that reads in part, "failed to
execute Mom agent service discovery script"... "the class name
'Win32_OperatingSystem' did not return any valid instances". Now, I know
a
fair amount about running scripts that use WMI. I dissected the Mom
Agent
Service Discovery script and found the section that throws the error and
I
modified the script to run as a WSH script and ran it against the server
that consistently throws the error. The WSH script returns instances
just
fine!

So, Mom seems to be installed correctly, as most of my agents are
running this script without any problem. WMI on the problem agent seems
to
be operating correctly as I can query it with a WSH script. The problem
agent is one of my remote Domain Controllers (I have 16 DCs in 13
locations). The link to that location is one of our better ones. That
is,
there are DCs in locations with less bandwidth and more latency that do
not
throw this error. So, netowrk connectivity does not seem to be the
issue.
The server with the problem does not have any errors in the event log
that
I
do not see on other servers and finally, the server is not particularly
more
busy than other servers in the system.

I am at a loss to know where to go from here. Does any one have any
ideas?

TIA
Dave Coate

*******************************
Here is the WSH version of the script that I mention above. As stated,
this
returns results just fine...

Option Explicit

Dim oOSCollection
Set oOSCollection = WMIGetInstance("winmgmts://" & "<servername>" &
"/root/cimv2", "Win32_OperatingSystem")
Dim oOS, OperatingSystemVersion
For Each oOS In oOSCollection
OperatingSystemVersion = oOS.Caption
Next
Wscript.Echo OperatingSystemVersion

Function WMIGetInstance(ByVal sNamespace, ByVal sInstance)
'
' WMIGetInstance :: Returns WMI Instance requested.
'
'
Dim oWMI, oInstance, nInstanceCount
'Dim e
'Set e = New Error
On Error Resume Next
Set oWMI = GetObject(sNamespace)
'e.Save
On Error Goto 0
If IsEmpty(oWMI) Then
ThrowScriptError "Unable to open WMI Namespace '" & sNamespace & "'.
Check to see if the WMI service is enabled and running, and ensure this
WMI
namespace exists.", e
End If

On Error Resume Next
Set oInstance = oWMI.InstancesOf(sInstance)
'e.Save
On Error Goto 0
If err.number <> 0 then Wscript.Echo err.number
If IsEmpty(oInstance) <> 0 Then
ThrowScriptError "The class name '" & sInstance & "' returned no
instances. Please check to see if this is a valid WMI class name.", e
End If

'Determine if we queried a valid WMI class - Count will return 0 or
empty

On Error Resume Next
nInstanceCount = oInstance.Count
'e.Save
On Error Goto 0
If err.Number <> 0 Then
ThrowScriptError "The class name '" & sInstance & "' did not return
any
valid instances. Please check to see if this is a valid WMI class
name.",
e
End If

Set WMIGetInstance = oInstance

End Function

Sub ThrowScriptError(str)
Wsctipt.Echo str
End Sub



[/quote]
Back to top
Arie de Haan
Guest





Posted: Tue Oct 18, 2005 4:51 pm    Post subject: Re: WMI scripts in Mom Reply with quote

In article <eYQMuFuzFHA.3660@TK2MSFTNGP15.phx.gbl>, coateds@comcast.net
says...
Quote:
Change the default impersonationLevel -

HKLM\Software\Microsoft\WBEM\scripting

Default Impersonation Level : DWORD : 3

This value was missing on the servers giving me the problem. After adding
the value I restarted the WMI and MOM services on the agent computer and all
is well running scripts that use WMI.


"Dave Coate" <coateds@comcast.net> wrote in message
Hi Dave,


thanks for letting us know, this could help some others
--
Greetz,

Arie
This posting is provide "AS IS" with no guarantees, warranties, rigths
etc.
Back to top
Alex
Guest





Posted: Wed Nov 09, 2005 1:50 am    Post subject: RE: WMI scripts in Mom Reply with quote

Did anyone ever find a resolution for this issue?
--
Alexander Larkin
Senior Enterprise Consultant
MCSE,MCSA,CCEA,MSA.


"Dave Coate" wrote:

Quote:
Hi All,

I have recently installed Mom 2005 SP1 into our production system and
deployed about 40 agents and the Base OS MP, the DNS MP and the DHCP MP. I
am now working on clearing errors and problems before deploying more. I have
several small issues with only some of the agents. Most of these are with
gathering WMI and Performance Counter data on some, but not all W2K SP4
servers. (the Mom server is W2K3 SP1) For now, I will focus on just one of
the more repeatable errors:

In the Mom Op console I get an error that reads in part, "failed to
execute Mom agent service discovery script"... "the class name
'Win32_OperatingSystem' did not return any valid instances". Now, I know a
fair amount about running scripts that use WMI. I dissected the Mom Agent
Service Discovery script and found the section that throws the error and I
modified the script to run as a WSH script and ran it against the server
that consistently throws the error. The WSH script returns instances just
fine!

So, Mom seems to be installed correctly, as most of my agents are
running this script without any problem. WMI on the problem agent seems to
be operating correctly as I can query it with a WSH script. The problem
agent is one of my remote Domain Controllers (I have 16 DCs in 13
locations). The link to that location is one of our better ones. That is,
there are DCs in locations with less bandwidth and more latency that do not
throw this error. So, netowrk connectivity does not seem to be the issue.
The server with the problem does not have any errors in the event log that I
do not see on other servers and finally, the server is not particularly more
busy than other servers in the system.

I am at a loss to know where to go from here. Does any one have any
ideas?

TIA
Dave Coate

*******************************
Here is the WSH version of the script that I mention above. As stated, this
returns results just fine...

Option Explicit

Dim oOSCollection
Set oOSCollection = WMIGetInstance("winmgmts://" & "<servername>" &
"/root/cimv2", "Win32_OperatingSystem")
Dim oOS, OperatingSystemVersion
For Each oOS In oOSCollection
OperatingSystemVersion = oOS.Caption
Next
Wscript.Echo OperatingSystemVersion

Function WMIGetInstance(ByVal sNamespace, ByVal sInstance)
'
' WMIGetInstance :: Returns WMI Instance requested.
'
'
Dim oWMI, oInstance, nInstanceCount
'Dim e
'Set e = New Error
On Error Resume Next
Set oWMI = GetObject(sNamespace)
'e.Save
On Error Goto 0
If IsEmpty(oWMI) Then
ThrowScriptError "Unable to open WMI Namespace '" & sNamespace & "'.
Check to see if the WMI service is enabled and running, and ensure this WMI
namespace exists.", e
End If

On Error Resume Next
Set oInstance = oWMI.InstancesOf(sInstance)
'e.Save
On Error Goto 0
If err.number <> 0 then Wscript.Echo err.number
If IsEmpty(oInstance) <> 0 Then
ThrowScriptError "The class name '" & sInstance & "' returned no
instances. Please check to see if this is a valid WMI class name.", e
End If

'Determine if we queried a valid WMI class - Count will return 0 or empty

On Error Resume Next
nInstanceCount = oInstance.Count
'e.Save
On Error Goto 0
If err.Number <> 0 Then
ThrowScriptError "The class name '" & sInstance & "' did not return any
valid instances. Please check to see if this is a valid WMI class name.", e
End If

Set WMIGetInstance = oInstance

End Function

Sub ThrowScriptError(str)
Wsctipt.Echo str
End Sub


Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> MOM All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB