Please enable Javascript for better experience...
 
VBScript - List a Perticular Service of All WMI Enabled Computers
By Pranay Jha | Feb 10, 2016 | In Articles | Total Views [ 471 ]
(1 Like)
Rate

On Error Resume Next

InputFile = ("c:\computers.txt")
OutputFile = ("c:\result.txt")
Service = ("netlogon")

Set oFS = CreateObject("Scripting.FileSystemObject")
Set f = oFS.OpenTextFile(InputFile)
Set fr = oFS.CreateTextFile(OutputFile, True)

Computers = f.ReadAll
f.Close
arrComputers = Split(Computers,  vbCrLf)

fr.WriteLine("Server" & vbTab & "Services" & vbTab & "State")

For Each strComputer in arrComputers
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")
    Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")

    For Each objService in colRunningServices 
        If objService.DisplayName = Service Then
            fr.WriteLine(strComputer & vbTab & objService.DisplayName & vbTab & objService.State)
        End If
    Next
Next
MsgBox "Service gathering complete", 0, "Info"


Thanks for visiting here. Share this article if you found it useful.
Join Facebook Group https://www.facebook.com/groups/VMwareInsight/
Like Facebook Page https://www.facebook.com/VMwareInsight/
Connect to twitter https://twitter.com/VMwareInsight
Share this on Social Media

About the Author

Pranay Jha
Pranay Jha
Founder, Contributer VMwareInsight.com
Follow me

facebook linkedin twitter G+ VMTN

My name is Pranay Jha, working in IBM as Technical Solution Architect for Virtualization platform. I have been working in IT for near around 11 years. Passionate to get involved as an Independent blogger for my blog http://vmwareinsight.com. I am carrying few industrial certifications as VMware vExpert 2016/2017, VCIX6, VCAP6-DCD, VCAP5-DCD/DCA, VCP6-DCVVCP5-DCV, VCA-Cloud, VCE-CIA, VSP, MCSE, MCITP, MCSA(Messaging). For any query or suggestion, please connect me at pranay1988jha@gmail.com. Thanks for visiting here.

 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment
 
Sponsors
 
 
 
 
 
Facebook Likes