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.
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.
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:
1 |
Get-CimInstance -ClassName Win32_Processor |
Display BIOS info
PowerShell command to collect the information about the system BIOS:
1 |
Get-CimInstance -ClassName Win32_BIOS |
Display computer manufacturer and model
PowerShell command to collect the computer model info:
1 |
Get-CimInstance -ClassName Win32_ComputerSystem |
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:
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.
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:
1 |
Get-CimInstance -ClassName Win32_QuickFixEngineering |
Display available disk space
PowerShell command to get the available disk space on the computer:
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:
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:
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
1 |
Get-ComputerInfo |
This command will return all the available properties of the system and the OS.
Display BIOS properties
1 |
Get-ComputerInfo -Property *BIOS* |
This command will return all the properties related to BIOS.
Display version properties
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
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.