Category filter

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 action from Hexnode.

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.

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:

Display BIOS info

PowerShell command to collect the information about the system BIOS:

Display computer manufacturer and model

PowerShell command to collect the computer model info:

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:

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.

List installed hotfixes

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

Display available disk space

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

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:

Display the local time from a computer

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

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

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

Display BIOS properties

This command will return all the properties related to BIOS.

Display version properties

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

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.

  • Sample Script Repository