[windows2000] Re: Problems with using WSH/WMI to check services on a Server

  • From: "Sullivan, Glenn" <GSullivan@xxxxxxxxxxxxxx>
  • To: <windows2000@xxxxxxxxxxxxx>
  • Date: Tue, 5 Oct 2004 08:16:32 -0400

Also, in your "For Each oServiceFRS in cServiceFRS" you are still
checking if DFS is running, not FRS.  It should read:
For Each oServiceFRS in cServiceFRS
        If oServiceFRS.Started = False Then
                iFRSCount = 1
        Else
                iFRSCount = 2
        End If
Next

If you add "Option Explicit" to the top of the script, and define all
your collection and object variables at the top, and remove the "On
error resume next" this will jump out at you.

Still looking at Quota/Event logs.
 

Glenn Sullivan, MCSE+I  MCDBA
David Clark Company Inc. 

 

________________________________

From: windows2000-bounce@xxxxxxxxxxxxx
[mailto:windows2000-bounce@xxxxxxxxxxxxx] On Behalf Of Sullivan, Glenn
Posted At: Tuesday, October 05, 2004 8:08 AM
Posted To: Windows 2000
Conversation: [windows2000] Problems with using WSH/WMI to check
services on a Server
Subject: [windows2000] Re: Problems with using WSH/WMI to check services
on a Server


Your "Else If" statements have to be "ElseIf"
 
I'll look at the other part of your request...

Glenn Sullivan, MCSE+I  MCDBA
David Clark Company Inc. 

 

________________________________

From: windows2000-bounce@xxxxxxxxxxxxx
[mailto:windows2000-bounce@xxxxxxxxxxxxx] On Behalf Of Spriggs Jon
Posted At: Monday, October 04, 2004 6:59 PM
Posted To: Windows 2000
Conversation: [windows2000] Problems with using WSH/WMI to check
services on a Server
Subject: [windows2000] Problems with using WSH/WMI to check services on
a Server


Hi,
 
I wonder if anyone can help me. I've been toying with the enclosed
script, and I can't make it work... I get so far through the script and
then it starts throwing up bugs...
 
Now, I know my knowledge of VBS, WSH and WMI is a little on the slow
side, but I've checked out all the If / Then / Else If / Else / End If
loops, and all the For / Next loops, and it doesn't *look* like I've
missed anything... have I? I'm using Windows 2k on the desktop (although
this is on an XP laptop as well) and 2k on the server.
 
I get an error message:
 
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
 
D:\pingserver.vbs(130, 7) Microsoft VBScript compilation error: Expected
'End'
 
If anyone can tell me how to cycle through the quotas set on a windows
2000 server with WMI and feed that into a text file, I'd be really
grateful - same with how to backup and reset event logs.
 
Thanks,
 
Jon Spriggs 
-- 
The presence of a "Fujitsu" address does not imply or assume that
Fujitsu Services, Fujitsu or any other company containing the Fujitsu
name uses or endorses this product. This email is purely a personal
opinion.
 
--- PingServer.vbs ---
 
On Error Resume Next
 
Dim sHost
Dim sTarget
Dim iSVRResp
Dim iTSCount
Dim iDHCPCount
Dim iDFSCount
Dim iFRSCount
 
sHost = "."
sTarget = "MyW2KServer"
iSVRResp = 0
iTSCount = 0
iDHCPCount = 0
iDFSCount = 0
iFRSCount = 0
 
Set cPingResults = GetObject("winmgmts://" & sHost & "/root/cimv2")._
      ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = '" +
sTarget + "'")
 
For Each oPingResult In cPingResults
 If oPingResult.StatusCode = 0 Then
 
  If oPingResult.ResponseTime > 100 Then 
   iSVRResp = 1 
  Else 
   iSVRResp = 2 
  End If
 
  Set cServiceTS = GetObject("winmgmts://" & sTarget & "/root/cimv2")._
    ExecQuery("SELECT * FROM Win32_Service WHERE DisplayName = 'Terminal
Services'")
 
  For Each oServiceTS in cServiceTS
   If oServiceTS.Started = False Then
    iTSCount = 1
   Else
    iTSCount = 2
   End If
 
  Next
  
  Set cServiceDHCP = GetObject("winmgmts://" & sTarget &
"/root/cimv2")._
    ExecQuery("SELECT * FROM Win32_Service WHERE DisplayName = 'DHCP
Server'")
  
  For Each oServiceDHCP in cServiceDHCP
   If oServiceDHCP.Started = False Then
    iDHCPCount = 1
   Else
    iDHCPCount = 2
   End If
 
  Next
  
  Set cServiceDFS = GetObject("winmgmts://" & sTarget & "/root/cimv2")._
    ExecQuery("SELECT * FROM Win32_Service WHERE DisplayName =
'Distributed File System'")
  
  For Each oServiceDFS in cServiceDFS
   If oServiceDFS.Started = False Then
    iDFSCount = 1
   Else
    iDFSCount = 2
   End If
 
  Next
 
  Set cServiceFRS = GetObject("winmgmts://" & sTarget & "/root/cimv2")._
    ExecQuery("SELECT * FROM Win32_Service WHERE DisplayName = 'File
Replication Service'")
 
  For Each oServiceFRS in cServiceFRS
 
   If oServiceDFS.Started = False Then
    iFRSCount = 1
   Else
    iFRSCount = 2
   End If
 
  Next
 
 Else
  iSVRResp = 0
 End If
Next
 
If iSVRResp = 2 AND iTSCount = 2 AND iDHCPCount = 2 AND iDFSCount = 2
AND iFRSCount = 2 Then
 
 wscript.echo "Server running and all Services Running OK"
 
Else
 
 If iSVRResp = 0 Then
  wscript.echo "Outage: Server Down (" & sTarget & ")"
 Else If iSVRResp = 1 Then
  wscript.echo "Warning: Server Slow (" & sTarget & ")"
 Else If iSVRResp = 2 Then
  wscript.echo "Server responds OK (" & sTarget & ")"
 End If
 
 If iTSCount = 0 Then
  wscript.echo "Warning: Terminal Services Service Does Not Exist On
This Server (" & sTarget & ")"
 Else If iTSCount = 1 Then
  wscript.echo "Outage: Terminal Services Service Has Stopped (" &
sTarget & ")"
 Else If iTSCount = 2 Then
  wscript.echo "Terminal Services Service OK (" & sTarget & ")"
 End If
 
 If iDHCPCount = 0 Then
  wscript.echo "Warning: DHCP Server Service Does Not Exist On This
Server (" & sTarget & ")"
 Else If iDHCPCount = 1 Then
  wscript.echo "Outage: DHCP Server Service Service Has Stopped (" &
sTarget & ")"
 Else If iDHCPCount = 2 Then
  wscript.echo "DHCP Server Service OK (" & sTarget & ")"
 End If
 
 If iDFSCount = 0 Then
  wscript.echo "Warning: DFS Service Does Not Exist On This Server (" &
sTarget & ")"
 Else If iDFSCount = 1 Then
  wscript.echo "Outage: DFS Service Service Has Stopped (" & sTarget &
")"
 Else If iDFSCount = 2 Then
  wscript.echo "DFS Service OK (" & sTarget & ")"
 End If
 
 If iFRSCount = 0 Then
  wscript.echo "Warning: FRS Service Does Not Exist On This Server (" &
sTarget & ")"
 Else If iFRSCount = 1 Then
  wscript.echo "Outage: FRS Service Service Has Stopped (" & sTarget &
")"
 Else If iFRSCount = 2 Then
  wscript.echo "FRS Service OK (" & sTarget & ")"
 End If
End If
********************************************************
This Weeks Sponsor StressedPuppy.com Games
Feeling stressed out? Check out our games to
relieve your stress.
http://www.StressedPuppy.com
********************************************************
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

http://thethin.net/win2000list.cfm

Other related posts: