Announcement

Collapse
No announcement yet.

Export Processor Type

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Export Processor Type

    I am using Hyena 5.2 and need to create a report of the types of processors in use within a NT Domain. Can Hyena do this?

    Thanks

  • #2
    Re: Export Processor Type

    Not at this time, but we are working on enhanced reporting/exporting that should allow for this.

    Comment


    • #3
      Re: Export Processor Type

      Will this do?

      '********** Begin Script ************
      '================================================= =========================
      '
      ' VBScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
      '
      ' NAME: GetProcessorType.vbs
      '
      ' AUTHOR: Joel Thoreson - joel.thoreson<nospam>@eustis.army.mil
      ' DATE : 6/26/2003
      '
      ' COMMENT: Scans all domain computers to see determine processor type.
      ' Results are displayed in a local (on the machine running
      ' the script) text file.
      ' Error trapping, output of errors (to both the screen And
      ' the output file), WBEM connection attempt if initial
      ' permissions fail, and much more...
      ' The output will show all computers, and write
      ' to the text file the exact status
      ' Uses NET VIEW piped results, and then uses a WMI
      ' function to "ping" each machine, therefore significantly
      ' speeding up the entire process by not scanning machines
      ' that are obviously offline
      '
      ' REQUIREMENTS: WMI/ADSI installed on ALL systems (log file will show
      ' which machines couldn't be scanned, and why)
      '================================================= =========================
      Option Explicit

      Dim WshShell, WshNetwork, fso, strDomain, strComputer, strOSVN
      Dim strFilePath, txtStreamOut, strTempFile, strRunPath, objTempFile, strTempLine
      Dim OS_Set, strSystemSet

      Const ForReading = 1 ' read access
      Const ForWriting = 2 ' write access

      ' Create the shell
      Set WshShell = WScript.CreateObject("WScript.Shell")

      ' Create FileSystemObject object to access file system.
      Set fso = WScript.CreateObject("Scripting.FileSystemObject")

      ' collect the argument sent
      If WScript.Arguments.Count <1 Then 'if nothing is passed, ask the user for input
      Set WshNetwork = CreateObject("WScript.Network")
      ' --- collect the argument from the user ------------------
      strDomain = UCASE(InputBox ("Enter the name of the target domain to run the scan upon." & vbCrLf & vbCrLf & _
      "Click OK to scan this domain." & vbCrLf & vbCrLf & _
      "Also note: Admin Rights (on the target computer) are required to run this script.","Processor Scan",WshNetwork.UserDomain,1400,1400))
      If strDomain = "" Then WScript.Quit
      Else ' a parameter was passed, so show the user the parameter passed and allow them to change it
      ' --- collect the argument from the script/cmd line -------
      strDomain = UCASE(InputBox ("Enter the name of the target domain to run the scan upon." & vbCrLf & vbCrLf & _
      "Click OK to scan this domain." & vbCrLf & vbCrLf & _
      "Also note: Admin Rights (on the target computer) are required to run this script.","Processor Scan",UCASE(Trim(WScript.Arguments(0))),1400,1400) )
      If strDomain = "" Then WScript.Quit

      End If

      ' Check the system launching the script
      '------------------------------------------------
      SysTest
      '------------------------------------------------

      ' set the text file path (could be made into an input box, with a default setting)
      strFilePath = "c:\Processors - " & strDomain & ".txt"

      ' Check whether the folder exists
      If (Not fso.FileExists(strFilePath)) Then ' File doesn't exist so create it
      fso.CreateTextFile(strFilePath)
      Else 'if it does, delete the old, create a new
      fso.DeleteFile(strFilePath)
      fso.CreateTextFile(strFilePath)
      End If

      Set txtStreamOut = fso.OpenTextFile(strFilePath, ForWriting, True) ' Open output

      txtStreamOut.WriteLine("Computers in the " & strDomain & " domain/workgroup " &_
      "and their processor information:")
      txtStreamOut.WriteLine 'blank line
      txtStreamOut.WriteLine ("Scan started at: " & Now)
      txtStreamOut.WriteLine 'blank line

      ' tell the user what is about to happen
      WshShell.Popup "This process will take some time to complete. You will see the status and the name of the machine currently " & _
      "being scanned. You'll be presented with a text file containing the names of " & _
      "of the systems and their processor information.",5,"Ready to Query Domain Computers",64
      ' set the temp file
      strTempFile = "c:\~" & strDomain & ".tmp"

      ' Check whether the file exists.
      If (fso.FileExists(strTempFile)) Then ' File exist; delete it (it will be created by the command itself)
      fso.DeleteFile(strTempFile)
      End If

      ' get a list of all computer in the domain, that are registered with the browser service at this time
      strRunPath = "cmd /c net view /domain:" & strDomain & " > " & strTempFile
      WshShell.Run(strRunPath)

      WScript.Sleep(5000) ' pause to allow the Run command to complete, increase as needed
      ' script will error on trying delete the strTempFile (after While Not...Wend loop) if not enough time is given

      ' set the temp file object
      Set objTempFile = fso.OpenTextFile(strTempFile, 1, false)
      'read until the end of the file
      While Not objTempFile.AtEndOfStream
      ' read the line
      strTempLine = objTempFile.ReadLine
      ' if the first 2 characters of the line are "\"
      If Left(strTempLine,2) = "\" Then
      ' get the machine name
      strComputer = Mid(Trim(Left(strTempLine,23)),3)
      'echo it to the display, so user can see progress. Can be commented out to run silently
      WshShell.Popup "Checking the processor on " & strComputer, 2, "Scanning..."
      '------------------------------------------------
      If WMIPing(strComputer) Then ' ping the machine to ensure it's online
      '------------------------------------------------
      '------------------------------------------------
      GetMachineInfo 'go get the machine info
      '------------------------------------------------
      If strOSVN = "NT" OR strOSVN = "2K" OR strOSVN = "XP" OR strOSVN = "2K3" Then 'NT system that has ADSI/WMI installed
      '------------------------------------------------
      CheckProcessor
      '------------------------------------------------
      Else 'the system either doesn't have ADSI/WMI installed, or access was denied
      If Err.Number = 462 Then 'can't reach the machine
      txtStreamOut.WriteLine strComputer & ": " & vbTab & "The remote server machine does not exist or is unavailable. (462)"
      Elseif Err.Number = 429 Then 'ActiveX component can't create object
      txtStreamOut.WriteLine strComputer & ": " & vbTab & "Check for ADSI/WMI on the system. Can't create ActiveX object. (429)"
      Elseif Err.Number = -2147217405 Then 'access denied
      txtStreamOut.WriteLine strComputer & ": " & vbTab & "Denied access to the system. Check for Admin Rights. (-2147217405)"
      Else 'if it's some other error, write it out
      txtStreamOut.WriteLine strComputer & ": " & vbTab & Err.Description & ". (" & Err.Number & ")"
      WScript.Echo Err.Description & ". (" & Err.Number & ")"
      End If
      Err.Clear
      End If
      Else
      If Err.Number = -2147217405 Then 'access denied
      txtStreamOut.WriteLine strComputer & ": " & vbTab & "Denied access to the system. Check for Admin Rights. (-2147217405 from WMI Ping)"
      Else
      txtStreamOut.WriteLine strComputer & ": " & vbTab & Err.Description & ". (" & Err.Number & ") - from WMI Ping"
      WScript.Echo Err.Description & ". (" & Err.Number & ") - from WMI Ping"
      End If
      End If
      End If
      Wend
      ' close the temp file
      objTempFile.Close
      ' delete the temp file
      fso.DeleteFile(strTempFile)
      ' finish writing to the log file
      txtStreamOut.WriteLine 'blank line
      txtStreamOut.WriteLine ("Scan completed at: " & Now)
      txtStreamOut.Close

      'End Script
      WshShell.Popup "The target system's processors have been scanned. " & _
      "Notepad will now open to display the results.", 3, "Exiting Script", vbInformation + vbOkOnly
      WshShell.Run ("Notepad.exe " & strFilePath)
      WScript.Quit

      '************************************************* ************************************************** ************
      'Function and subroutines follow

      '************************************************* ************************************************** ************
      ' - Use WMI to check if the computer is reachable. Faster than waiting for an Error
      ' - Thanks mucho to:
      ' Jeffery Hicks
      ' [email protected] http://www.quilogy.com
      '************************************************* ************************************************** ************
      Function WMIPing(strSrv) 'function returns TRUE if successful contact was made.

      On Error Resume Next
      Dim oWMI, oRef, strQuery, item

      Const ReturnImmediately=&h10
      Const ForwardOnly=&h20

      strQuery="Select CSName,Status FROM Win32_OperatingSystem"

      Set oWMI=GetObject("Winmgmts://" & strSrv)

      If Err.Number Then
      WMIPing=False
      Exit Function
      End If

      Set oRef=oWMI.ExecQuery(strQuery, "WQL", ForwardOnly + ReturnImmediately)

      If Err.Number Then
      WMIPing=False
      Exit Function
      End If

      for each item in oRef
      If item.Status="OK" Then
      WMIPing=True
      Else
      WMIPing=False
      End If
      Next
      Set strQuery = Nothing
      Set oWMI = Nothing
      set oRef = Nothing

      On Error Goto 0

      End Function
      '************************************************* ************************************************** **********

      '************************************************* ************************************************** **********
      ' Function to check what the operating system is on a machine
      ' This will only work on XP, 2K and 2K3 machines out of the box.
      ' For this to work on NT, you must install ADSI and WMI (upgrading to VBScript 5.6 won't hurt either)
      ' For 9x boxes, same thing applies; although results returned from ADSI/WMI on Win9x boxes can be fishy at times
      '************************************************* ************************************************** ************
      Function GetMachineInfo
      'Local variables
      Dim os_version, os_svcpk
      Dim strSystem
      Dim system_roletmp, strMessage

      On Error Resume Next ' so we can catch the errors and "do the right thing"

      ' - here we attempt to connect using straight up WMI connection (with existing credentials)
      Set OS_Set = GetObject("winmgmts:{impersonationLevel=impersonat e}//" & strComputer).InstancesOf ("Win32_OperatingSystem")

      ' - if there's an error, we catch the ADSI/WMI error (usually on NT & 9x machines), then...
      If Err.Number = 429 Then
      strMessage = "ADSI 5.2 **AND** WMI must be installed on local workstation to continue." & vbCrLf & VbCrLf & _
      "These updates can be found at:" & vbCrLf & VbCrLf & _
      "\\krait\public\NT and 2K-XP Pro Tools, Upgrades & Patches\Patches, Upgrades and Updates from Microsoft" & vbCrLf & VbCrLf & _
      "'Windows Management Instrumentation (WMI) CORE 1.5 (Windows NT 4.0).EXE'" & vbCrLf & _
      "'Microsoft Active Directory Services Interfaces 2.5 for Intel X86 - Windows NT.exe'" & vbCrLf & VbCrLf & _
      "Failure to install the required software will result in this message every time you run this utility."
      WshShell.Popup strMessage,10,UCASE(strComputer) & " must be updated",vbCritical
      'maybe put something in here to install the updates automatically, or launch a web page where the user can install them
      'but for this script, we don't want to "WScript.Quit", we want the script to just skip to the next machine
      Exit Function
      ' - ...or we catch that the machine is no longer online or available
      Elseif Err.Number = 462 Then
      Exit Function
      ' - ...or we catch the "Access Denied" or "Permission Denied", if it comes up. We could attempt to use WBEM to connect
      ElseIf Err.Number <> 0 Then Exit Function
      End If

      On Error GoTo 0 'reset the error trap

      For each strSystem in OS_Set
      os_version = strSystem.Version
      os_svcpk = strSystem.CSDVersion
      'Get the proper name for the version
      ' and set the system_role variable for 9x Workstations so that
      ' it can be utilized a little farther down to skip a step
      If os_version = "4.00.950" and os_svcpk = "" then
      'Windows 95 Retail, OEM
      strOSVN = "95"
      system_role = "Windows 9x Workstation"
      ElseIf os_version = "4.00.950" and os_svcpk = "A" then
      'Windows 95 Retail SP1
      strOSVN = "95"
      system_role = "Windows 9x Workstation"
      ElseIf os_version = "4.00.1111" then
      'Windows 95 OEM Release 2 (95B)
      strOSVN = "95"
      system_role = "Windows 9x Workstation"
      ElseIf os_version = "4.00.1212" then
      'Windows 95 OEM Release 2.1 (95B)
      strOSVN = "95"
      system_role = "Windows 9x Workstation"
      ElseIf os_version = "4.00.1215" then
      'Windows 95 OEM Release 2.1 (95C)
      strOSVN = "95"
      system_role = "Windows 9x Workstation"
      ElseIf os_version = "4.10.1998" then
      'Windows 98 Retail, OEM
      strOSVN = "98"
      system_role = "Windows 9x Workstation"
      ElseIf os_version = "4.10.2222" then
      'Windows 98 Second Edition
      strOSVN = "98SE"
      system_role = "Windows 9x Workstation"
      ElseIf os_version = "4.90.3000" then
      'Windows Millennium Edition (ME)
      strOSVN = "ME"
      system_role = "Windows 9x Workstation"
      ElseIf os_version = "4.0.1381" then
      'Windows NT 4.0
      strOSVN = "NT"
      ElseIf os_version = "5.0.2195" then
      'Windows 2000 Professional
      strOSVN = "2K"
      ElseIf os_version = "5.1.2600" then
      'Windows XP Professional
      strOSVN = "XP"
      ElseIf os_version = "5.2.3790" then
      'Windows 2003 Server
      strOSVN = "2K3"
      End If
      Next
      End Function
      '************************************************* ************************************************** ************

      '************************************************* ************************************************** ************
      ' Function to check the processor
      '************************************************* ************************************************** ************
      Function CheckProcessor
      ' local variables
      Dim objWMIService, colItems, objItem
      On Error Resume Next
      Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")
      Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
      ' enumerate the objects, and write them to the log file
      For Each objItem in colItems
      txtStreamOut.WriteLine strComputer & ":"
      txtStreamOut.WriteLine "CurrentClockSpeed: " & objItem.CurrentClockSpeed
      txtStreamOut.WriteLine "Description: " & Trim(objItem.Description)
      txtStreamOut.WriteLine "DeviceID: " & objItem.DeviceID
      txtStreamOut.WriteLine "L2CacheSize: " & objItem.L2CacheSize
      txtStreamOut.WriteLine "Manufacturer: " & Trim(objItem.Manufacturer)
      txtStreamOut.WriteLine "MaxClockSpeed: " & objItem.MaxClockSpeed
      txtStreamOut.WriteLine "Name: " & Trim(objItem.Name)
      txtStreamOut.WriteLine "ProcessorId: " & Trim(objItem.ProcessorId)
      txtStreamOut.WriteLine "SocketDesignation: " & objItem.SocketDesignation
      txtStreamOut.WriteLine "SystemName: " & Trim(objItem.SystemName)
      txtStreamOut.WriteLine "-----------------------------------------------------------" & vbCrLf
      Next
      End Function
      '************************************************* ************************************************** ************

      '************************************************* ************************************************** ************
      ' Subroutine to check the system the script is running on to ensure it has ADSI/WMI/VBScript
      '************************************************* ************************************************** ************
      Sub SysTest()
      Dim Major, Minor, Ver, Message, key, key2
      On Error Resume Next
      ' WSH version tested
      Major = (ScriptEngineMinorVersion())
      Minor = (ScriptEngineMinorVersion())/10
      Ver = Major + Minor
      'Need version 5.5
      If Err.Number or Ver <= 5.5 then
      Message = "You have WScript Version " & Ver & ". Please load Version 5.6"
      End If

      'Test for ADSI
      Err.Clear
      key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{E92B03AB-B707-11d2-9CBD-0000F87A369E}\version"
      key2 = WshShell.RegRead (key)
      if err <> 0 then
      Message = Message & "ADSI must be installed on local workstation to continue" & vbCrLf
      WshShell.Popup message,0,"Workstation Setup Error",vbInformation
      WScript.Quit
      End If
      On Error GoTo 0

      End Sub
      '************************************************* ************************************************** ************
      '************* End Script ****************

      Save this script as GetProcessorType.vbs

      Create a tool in Hyena to run this script. Command line should go something like this:

      "wscript.exe c:\GetProcessorType.vbs //I //NoLogo %E%"

      This assumes that you save the script to your "C:", change the path as needed.

      This will display a text file chock-full-o-info on the processor(s) of each machine. I say processor(s) because it will report all info if a system has more than one.

      Hope this helps! Sorry, but for me to 'port' this stuff to the Hyena database, I'd have to add a "few" more lines, and this script's big enough, ya think?

      Joel

      Comment


      • #4
        Re: Export Processor Type

        Thanks! that is quite an impressive script and it does exactly what I needed!

        Comment


        • #5
          Re: Export Processor Type

          I copied the script and set it up to run, but everytime I run it I get a stop error that says there is a error in the script at line:150 char:1 Error:Permission denied Code:800A0046 Source:microsoft VBScript runtime error. Any ideas? I'm not a script guru so any help would be appreciated.

          Comment


          • #6
            Re: Export Processor Type

            <div class="ubbcode-block"><div class="ubbcode-header">Quote:</div><div class="ubbcode-body">Originally posted by bfitzpa:
            <span style="font-weight: bold">I copied the script and set it up to run, but everytime I run it I get a stop error that says there is a error in the script at line:150 char:1 Error:Permission denied Code:800A0046 Source:microsoft VBScript runtime error. Any ideas? I'm not a script guru so any help would be appreciated.</span></div></div>

            I just tested it using the domain name and it seems to work fine, but it scans all machines in the domain. Far too long. It's only when I put in a individual machine name that it fails with the error.

            Comment


            • #7
              Re: Export Processor Type

              The problem is just that. This script does it by domain name, not computer name.

              In other words, when you pass it a computer name, it tries to find a domain with that name, and scan it.

              Modifying the script to do one computer and export the info to a text file wouldn't be logical. Individual processor information is available from Hyena's Properties.

              Or...

              The script could be modified (in the arguments section) to ask the user if the parameter passed is a Domain or Individual computer, and then, rather than creating an individual file for each entry, append to one particular file.

              Just what is it you're looking for?

              Joel

              Comment

              Working...
              X