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 [ 2572 ]
(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.
Like Facebook Page https://www.facebook.com/VMwareInsight/
Connect to twitter https://twitter.com/imPranayK
Subscribe my Channel https://www.youtube.com/vmwareinsight
Connect over Linkedin https://in.linkedin.com/in/impranayk
Share this on Social Media

About the Author

Pranay Jha
Pranay Jha
Founder, Contributer VMwareInsight.com

Public profile: user/profile/99900000


Follow me

facebook linkedin twitter G+ VMTN youtube

Thank you for visiting my profile. I am Pranay Jha, bring along a total of 11+ years of extensive experience with me in Information Technology sector for organizations from small business to large enterprises, wherein my current assignment I am associated with IBM as a Technical Solution Architect for Virtualization platform. I am vExpert x 3 (16/17/18), VCIX-DCV, VCAP5/6-DCD, VCAP5-DCA, VCP7-CMA, VCP5/6-DCV, VCA-DCV, VCA-Cloud, VSP, VCE-CIA, MCITP, MCSE, MCSA(Messaging). I am also an Independent blogger and founder of http://vmwareinsight.com and https://cloudpathshala.com. I can be reached via email at pranay1988jha@gmail.com or Direct Message via Contact Us form.

 
Please SignUp/Login to comment...

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