Quick System Information Grab

4 minute read time.

I wish there was one way to get information about an environment, regardless of the type of environment your looking at. Meaning, some systems have SQL installed, others have a web server installed, some operating systems are newer and some are older, some have a print server installed and so forth. And for some reason, Microsoft just can’t make their mind up on exactly which library to use to get at this information. Here at Sage Support I often find myself using a different set of tools at different times, depending on the compatibility of that tool type with the customer’s operating system, version of SQL, etc..

So, on this article, I’d like to provide a very quick overview of the different tools I have used in the past, on some of our more crazy support issues and give a couple examples just to get you used to the syntax. By the end, I bet like me, you too will wish there was only one way to get this information, and all Microsoft’s tools used the same technique!

Powershell (Flavor of the month)

Computer System Information

Drop to a command prompt and type PowerShell then run the following line

   1: gwmi–q “SELECT * FROM win32_computersystem”

Alternatively you can simply run Powershell and run the same line, you will get the same results either way.

image

I tend to use this if I’m quickly trying to find out if a machine is virtualized. My experience has been the model will read Virtual Machine or something similar to that. If it is a physical machine, usually the machine will have a brand name, like DELL.

Of course, you can also get this same information form the computer properties (windows button + pause button) on newer operating systems.

You can learn more about PowerShell from the scripting guys, found here: http://technet.microsoft.com/library/bb978526.aspx.

SystemInfo Command

Again, drop to a command prompt and type the following

   1: systeminfo >c:\temp\systeminfo.log

After this is completed you will get a log that will provide you information about the BIOS, memory, host name, operating system, the Microsoft patches that are installed, the NIC cards and more.

image

 

WMI Command Line Tool

Of course, not to be overshadowed are the WMI command line tools, you can find all kinds of useful fun facts with these classes.

Example 1: Windows Experience Score (for applicable operating systems)

Drop to a command line prompt and type the following:

   1: wmic path Win32_WinSAT get CPUScore, D3DScore, DiskScore, MemoryScore, WinSPRLevel

You should see an output like the following, of course your numbers are probably much better than mine.

image

Newer systems dropped support for Win32_WinSAT, but you could check other things through WMIC, such as the DISKDRIVE class, or the page file class.

Example 2: Windows Page Page File

   1: WMIC PAGEFILE GET * /format:htable >c:\temp\pagefile.htm

This will create an html report with facts about the page file

image

Example 3: Disk Drive Information

   1: WMIC DISKDRIVE GET * /format:htable >c:\temp\diskDrive3.htm

 

There are more types of WMIC queries you can run. You can learn more here:

http://blogs.technet.com/b/askperf/archive/2012/02/17/useful-wmic-queries.aspx

Example 4: SCSI Controller Information

   1: WMIC SCSICONTROLLER GET * /format:list

Example output

image

 

Example 5: ComputerSystem

Of course, WMI queries would feel left out if they didn’t have their own version of the computer system information, so here you go:

   1: WMIC COMPUTERSYSTEM GET Name, domain, Manufacturer, Model, NumberofProcessors, PrimaryOwnerName, Username, Roles, totalphysicalmemory /format:list

Example output

image

 

SQL Server: Get System Information

SQL also exposes system information through a variety of diagnostic manager views and server properties. Down below is a common query I run on customer systems.

Note: This query may not run on older versions of SQL. If you receive errors try eliminating the sub select queries at the bottom and only query the SEVERPROPERTY fields instead.

SELECT 
       SERVERPROPERTY('BuildClrVersion') BuildClrVersion,
       SERVERPROPERTY('Collation') Collation, 
       SERVERPROPERTY('CollationID') CollationID,
       SERVERPROPERTY('ComparisonStyle') ComparisonStyle,
       SERVERPROPERTY('ComputerNamePhysicalNetBIOS') ComputerNamePhysicalNetBIOS,
       SERVERPROPERTY('Edition') Edition,
       SERVERPROPERTY('EditionID') EditionID,
       SERVERPROPERTY('EngineEdition') EngineEdition,
       SERVERPROPERTY('InstanceName') InstanceName,
       SERVERPROPERTY('IsClustered') IsClustered,
       SERVERPROPERTY('IsFullTextInstalled') IsFullTextInstalled,
       SERVERPROPERTY('IsIntegratedSecurityOnly') IsIntegratedSecurityOnly,
       SERVERPROPERTY('IsSingleUser') IsSingleUser,
       SERVERPROPERTY('LCID') LCID,
       SERVERPROPERTY('LicenseType') LicenseType,
       SERVERPROPERTY('MachineName') MachineName,
       SERVERPROPERTY('NumLicenses') NumLicenses,
       SERVERPROPERTY('ProcessID') ProcessID,
       SERVERPROPERTY('ProductVersion') ProductVersion,
       SERVERPROPERTY('ProductLevel') ProductLevel,
       SERVERPROPERTY('ResourceLastUpdateDateTime') ResourceLastUpdateDateTime,
       SERVERPROPERTY('ResourceVersion') ResourceVersion,
       SERVERPROPERTY('ServerName') ServerName,
       SERVERPROPERTY('SqlCharSet') SqlCharSet,
       SERVERPROPERTY('SqlCharSetName') SqlCharSetName,
       SERVERPROPERTY('SqlSortOrder') SqlSortOrder,
       SERVERPROPERTY('SqlSortOrderName')SqlSortOrderName,
       (SELECT windows_release from sys.dm_os_windows_info) WindowsReleaseNumber,
       (SELECT windows_service_pack_level from sys.dm_os_windows_info) WindowsServicePack, 
       (SELECT system_memory_state_desc FROM sys.dm_os_sys_memory) SystemMemoryStateDesc,
       (SELECT cpu_count FROM sys.dm_os_sys_info) CpuCount,
       (SELECT affinity_type_desc FROM sys.dm_os_sys_info) AffinityMask,
       (SELECT hyperthread_ratio FROM sys.dm_os_sys_info) HyperthreadRation,
       (SELECT (physical_memory_kb / 1024) FROM sys.dm_os_sys_info) PhysicalMemoryMB,
       (select sqlserver_start_time FROM sys.dm_os_sys_info) SQLServerStartTime,
       (SELECT virtual_machine_type_desc FROM sys.dm_os_sys_info) VirtualizationType



Conclusion

As you can see, there are many tools out there to get you a quick system information grab. As mentioned before, not all these tools will work on every operating system, they are version dependent. But this list is a good start at getting some insight into a new system you haven’t seen before.

Happy scripting.