[intertech] Re: Two New Scripts

  • From: "Brian Smyth" <mail@xxxxxxxxxxxxxx>
  • To: <intertech@xxxxxxxxxxxxx>
  • Date: Fri, 19 Nov 2004 15:44:45 -0000

This is the last time, promise. These new ones output to a csv file which
opens in Excel, which is much easier for reports and stuff. Rename to .vbs
instead of .txt and execute to run them.

 

Cheers,

Brian

 

  _____  

From: intertech-bounce@xxxxxxxxxxxxx [mailto:intertech-bounce@xxxxxxxxxxxxx]
On Behalf Of Brian Smyth
Sent: 19 November 2004 15:08
To: intertech@xxxxxxxxxxxxx
Subject: [intertech] Two New Scripts

 

Here are two new scripts for gathering information from a specified server

 

Brian

'###########################################
'  This script was created by Brian Smyth
'  19 November 2004 14:39
'###########################################

Dim objFileSystem, objOutputFile
Dim strOutputFile
Dim strTargetCompName

strTargetCompName = InputBox("Enter Name of the Server to query:")
strText = ""
strOutputFile = "Hotfix List for " + strTargetCompName + ".csv"

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
Set objWMIService = GetObject("winmgmts:" & 
"{impersonationLevel=impersonate}!\\" & strTargetCompName & "\root\cimv2")
Set colQuickFixes = objWMIService.ExecQuery ("Select * from 
Win32_QuickFixEngineering")

objOutputFile.WriteLine("The following is a list of hotfixes on the following 
system: " & vbCrLf & strTargetCompName & vbCrLf & vbCrLf)
objOutputFile.WriteLine("Computer, Description, Hotfix ID, Installation Date, 
Installed By" & vbCrLf & vbCrLf)

For Each objQuickFix in colQuickFixes
  objOutputFile.WriteLine(objQuickFix.CSName & ", " & objQuickFix.Description & 
", " & objQuickFix.HotFixID & ", " & objQuickFix.InstallDate & ", " & 
objQuickFix.InstalledBy)

Next

Set objFileSystem = Nothing
'###########################################
'  This script was created by Brian Smyth
'  19 November 2004 14:39
'###########################################

Dim objFileSystem, objOutputFile
Dim strOutputFile
Dim strTargetCompName

strTargetCompName = InputBox("Enter Name of the Server to query:")
'strTargetCompName = "bs-compaq"
strText = ""
strWMIMoniker = "WinMgmts:!//" + strTargetCompName
strQuery = "select * from Win32_Service"
strOutputFile = "Services List for " + strTargetCompName + ".csv"

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
Set wmiWin32Services = GetObject(strWMIMoniker).ExecQuery(strQuery)

objOutputFile.WriteLine("The following is a list of services on the following 
system: " & vbCrLf & strTargetCompName & vbCrLf & vbCrLf)
objOutputFile.WriteLine("Caption, Name, State, Startup Mode, Status, Started, 
StartName, Description" & vbCrLf & vbCrLf)

For Each wmiWin32Service in wmiWin32Services
objOutputFile.WriteLine(wmiWin32Service.caption & ", " & wmiWin32Service.name & 
", " & wmiWin32Service.state & ", " & wmiWin32Service.startmode & ", " & 
wmiWin32Service.status & ", " & wmiWin32Service.started & ", " & 
wmiWin32Service.startname & ", " & wmiWin32Service.description)

Next

Set objFileSystem = Nothing

Other related posts: