Answered by:
script to find stopped services.

Question
-
I am trying to find any services that are set to automatic that are stopped to alert to scom. If the service is set to automatic(delayed startup) i want to ignore these ones. It seems when I try to use the DelayedAutoStart variable under the Win32_service variable it give me an error as follows:
C:\Temp\test.vbs(12, 2) Microsoft VBScript runtime error: Object doesn't support
this property or method: 'DelayedAutoStart'here is my script:
'Declare Variables
Dim objWMIService, objProcess, colProcess, Status, strComputer, strService, oAPI, oBag
Status= true
strComputer = "."
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag= oAPI.CreatePropertyBag()
Set objWMIService = GetObject("winmgmts:"& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("SELECT * FROM Win32_Service ")
For Each objProcess in colProcess
if (objProcess.StartMode="Auto") and (objProcess.state <> "Running") and (objProcess.DelayedAutoStart <> 0) then
'message=message & objProcess.DisplayName & " " & objProcess.State & " " & objProcess.StartMode & vblf & vbcr
status=false
call oBag.AddValue("Status","NOT OK")
call oBag.AddValue("Service",objProcess.DisplayName)
Exit For
End If
Next
if status=True then
call oBag.AddValue("status","OK")
end if
call oBag.AddValue("status","OK")
call oAPI.return(obag)Saturday, November 18, 2017 8:03 PM
Answers
-
You might look around here.
https://gallery.technet.microsoft.com/scriptcenter/
or ask for help over here.
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
https://social.msdn.microsoft.com/Forums/en-US/home?forum=scripting
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by Richard MuellerMVP, Banned Saturday, November 18, 2017 9:26 PM
- Marked as answer by Richard MuellerMVP, Banned Sunday, November 26, 2017 8:34 AM
Saturday, November 18, 2017 9:01 PM -
You could use a PowerShell script to find the stopped services. Example:
Get-Service | Select -Property Name, Status, StartType | Where-Object {(($_.Status -notmatch "Running") -and ($_.StartType -notmatch "Manual") -and ($_.StartType -notmatch "Disabled") -and ($_.StartType -notmatch "Delayed"))}
Maurice Daly
Microsoft MVP Enterprise Mobility
SCConfigMgr.com- Marked as answer by Richard MuellerMVP, Banned Sunday, November 26, 2017 8:35 AM
Saturday, November 18, 2017 9:42 PM
All replies
-
You might look around here.
https://gallery.technet.microsoft.com/scriptcenter/
or ask for help over here.
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
https://social.msdn.microsoft.com/Forums/en-US/home?forum=scripting
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by Richard MuellerMVP, Banned Saturday, November 18, 2017 9:26 PM
- Marked as answer by Richard MuellerMVP, Banned Sunday, November 26, 2017 8:34 AM
Saturday, November 18, 2017 9:01 PM -
You could use a PowerShell script to find the stopped services. Example:
Get-Service | Select -Property Name, Status, StartType | Where-Object {(($_.Status -notmatch "Running") -and ($_.StartType -notmatch "Manual") -and ($_.StartType -notmatch "Disabled") -and ($_.StartType -notmatch "Delayed"))}
Maurice Daly
Microsoft MVP Enterprise Mobility
SCConfigMgr.com- Marked as answer by Richard MuellerMVP, Banned Sunday, November 26, 2017 8:35 AM
Saturday, November 18, 2017 9:42 PM