# Script to collect Windows system information

As an IT administrator of an organization, you might have numerous reasons to gather various device information about your Windows endpoints. For example, you might need specific info regarding the system for troubleshooting or to check the feasibility of running a software application. There are multiple ways to achieve this:

- Using the *System Information* tool
- Third-party applications
- Executing commands via the Command Prompt or PowerShell

Achieving this manually across a large fleet of devices may not be feasible. Instead, you can remotely fetch the required computer information by running scripts via the [Execute Custom Script](https://www.hexnode.com/mobile-device-management/help/executing-custom-scripts-for-windows/) action from Hexnode.

 Note: 
**Supported Versions**:

The scripts given below will be supported on the following versions:

- Windows 10 v1607+ (Pro, Enterprise, Education)
- Windows 11 (Pro, Enterprise, Education)

 

 Disclaimer:The sample scripts provided below are adapted from third-party open-source sites.

 

 Batch command to collect Windows system information 
-----------------------------------------------------

The following batch command will display a comprehensive list of device information such as the BIOS version, processor info, product ID, boot drive info, network details, etc.

Batch script to collect Windows System Information

systeminfo

   1

  systeminfo

   

 

  

 PowerShell commands to collect Windows device information 
-----------------------------------------------------------

*Get-CimInstance* and *Get-Computerinfo* are two of the most widely used cmdlets to collect Windows device information. Let’s look at each of them separately.

Get-CimInstance
---------------

You can use the *Get-CimInstance* cmdlet and specify the correct WMI class to query information about a Windows device through the WMI (Windows Management Instrumentation) service. Each WMI class represents specific device-related info.

### Display processor info 

You can retrieve the processor information using *Win32\_Processor* class. The following PowerShell command will display the general details about the device processor:

PowerShell script to display processor info

Get-CimInstance -ClassName Win32\_Processor 

   1

  Get-CimInstance -ClassName Win32\_Processor 

   

 

  

### Display BIOS info 

PowerShell command to collect the information about the system BIOS:

PowerShell script to display BIOS info

Get-CimInstance -ClassName Win32\_BIOS 

   1

  Get-CimInstance -ClassName Win32\_BIOS 

   

 

  

### Display computer manufacturer and model

PowerShell command to collect the computer model info:

PowerShell script to display computer manufacturer and model info

Get-CimInstance -ClassName Win32\_ComputerSystem 

   1

  Get-CimInstance -ClassName Win32\_ComputerSystem 

   

 

  

 Note:Some information may not be correctly configured by hardware manufacturers and will therefore be unavailable on running above the command.

 

### List operating system version information 

You can use the *Win32\_OperatingSystem* class to list the version and service pack information of the device’s operating system.

PowerShell command:

PowerShell script to display OS version info

Get-CimInstance -ClassName Win32\_OperatingSystem | Select-Object -Property Build\*,OSType,ServicePack\* 

   1

  Get-CimInstance -ClassName Win32\_OperatingSystem | Select-Object -Property Build\*,OSType,ServicePack\* 

   

 

  

### List local users 

Local user information such as the registered owner and number of users can also be collected using the *Win32\_OperatingSystem* class by specifying the required properties.

The PowerShell command below can be used to list the number of licensed users, the current number of users and the owner name.

PowerShell script to list the local users

Get-CimInstance -ClassName Win32\_OperatingSystem | Select-Object -Property NumberOfLicensedUsers,NumberOfUsers,RegisteredUser 

   1

  Get-CimInstance -ClassName Win32\_OperatingSystem | Select-Object -Property NumberOfLicensedUsers,NumberOfUsers,RegisteredUser 

   

 

  

### List installed hotfixes

Run the following PowerShell command to get a list of hotfixes installed on the device:

PowerShell script to list the installed hotfixes

Get-CimInstance -ClassName Win32\_QuickFixEngineering 

   1

  Get-CimInstance -ClassName Win32\_QuickFixEngineering 

   

 

  

### Display available disk space 

PowerShell command to get the available disk space on the computer:

PowerShell script to display available disk space 

Get-CimInstance -ClassName Win32\_LogicalDisk 

   1

  Get-CimInstance -ClassName Win32\_LogicalDisk 

   

 

  

The above command will return info about all the drives on the Windows device. To filter out information about a specific drive, you can use the *DriveType* parameter.

For example, to get the available disk space on fixed hard disks:

`Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" `

### Display the user logged on to a computer 

PowerShell command to display the user logged on to the Windows device:

PowerShell script to display the logged on user

Get-CimInstance -ClassName Win32\_ComputerSystem -Property UserName 

   1

  Get-CimInstance -ClassName Win32\_ComputerSystem -Property UserName 

   

 

  

### Display the local time from a computer 

Execute the following PowerShell command to get the current local time on the computer:

PowerShell script to display the local time

Get-CimInstance -ClassName Win32\_LocalTime 

   1

  Get-CimInstance -ClassName Win32\_LocalTime 

   

 

  

Get-ComputerInfo
----------------

You can use the *Get-ComputerInfo* cmdlet to return properties of the system and its operating system.

### Display all system and OS properties

PowerShell script to get computer info

Get-ComputerInfo 

   1

  Get-ComputerInfo 

   

 

  

This command will return all the available properties of the system and the OS.

### Display BIOS properties

PowerShell script to get BIOS properties

Get-ComputerInfo -Property \*BIOS\*

   1

  Get-ComputerInfo -Property \*BIOS\*

   

 

  

This command will return all the properties related to BIOS.

### Display version properties

PowerShell script to get version properties

Get-ComputerInfo -Property "\*version”

   1

  Get-ComputerInfo -Property "\*version”

   

 

  

This command will return the version properties, i.e., the different types of versions associated with the device, the operating system and BIOS. For example, these are a few of the versions listed:

- Windows version
- BIOS version
- BIOS major version
- BIOS minor version
- OS version

### Display specific OS details

PowerShell script to get specific OS details

Get-ComputerInfo | Select OSName, OSVersion, OSLastBootupTime

   1

  Get-ComputerInfo | Select OSName, OSVersion, OSLastBootupTime

   

 

  

Use this command when you want any specific information about the OS. This command will return the operating system’s name, version and the exact date and time when it was last booted.

 Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.