[intertech] Two New Scripts

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

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 + ".txt"

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)

For Each objQuickFix in colQuickFixes
  objOutputFile.WriteLine("Computer: " & objQuickFix.CSName)
  objOutputFile.WriteLine("Description: " & objQuickFix.Description)
  objOutputFile.WriteLine("Hotfix ID: " & objQuickFix.HotFixID) 
  objOutputFile.WriteLine("Installation Date: " & objQuickFix.InstallDate) 
  objOutputFile.WriteLine("Installed By: " & objQuickFix.InstalledBy & vbCrlf & 
vbCrlf)
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 + ".txt"

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)

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

'               objOutputFile.WriteLine(wmiWin32Service.systemname)

Next

Set objFileSystem = Nothing

Other related posts: