PowerShell script to get computer information
PowerShell script to get computer information.
When there is a support case, the first thing that you need to do it to gather as much information as possible related to the issue, so you will start troubleshooting. The information that you can receive from a computer using PowerShell is a lot. In cases that some software may run slow and in general the PC of a user is slow, the first thing that you need to know is what PC is using and some basic specifications. I came up with this simple script to receive the basic information and present it to you so you will be able to see those specifications. In general the script will gather information about Manufacturer and Model, CPU, RAM, Disks and Operating System.
Let see in more detail
The first part of the script in only the help information that is provided through Get-Help for the script. To run the script you need to provide always the computer name of the PC. The script first will receive the value that you have provided and will test if the PC is reachable. If the value that you have provided is wrong or the PC is not reachable then it will inform you and will exit. If the value is correct and the computer is reachable, then it will start the process of gathering the information from the computer.
The first information that the script will gather is the Manufacturer and Model of the PC. After that the script will collect the information for the CPU/s. It will get the id of the CPU if there are multiple CPUs and the model of the CPU. The next two commands are related to the information of RAM. The first command check the number of RAM DIMMs that the PC has and also the total RAM of the PC. Please note that the value provided for the Total RAM Capacity is in KBytes. The second command will gather the information for each DIMM. It will provide us with the location on the Motherboard, the manufacturer of the RAM and the part number, the capacity of each DIMM and the speed that is configured.
The script will continue on the information from the disks and will receive the information from the disk such as Drive Letter, the name of the drive if it exists, total size of the disk and the free space. Please note that the Disk sizes are provided in Bytes.
Operating System Version
The script as a final information will gather the version of Windows. The version is provided in released version number based on NT System. As this was not clear which was the version, I had to relate the edition number with a common name with is more readable. The script has been tested only on Windows 8.1 and Windows 10, but in the list I have included also Windows 7. Any other Windows version it will give you Unknown Operating System. It is unknown, not because you cannot retrieve the information but because I have not correlate it with any Windows version. Another important thing that it has to be mentioned is the Windows Servers, have the same NT release version. In this script I have not considered any Windows Server modes, so the Operating System information will be wrong.
This is only a simple script that retrieves basic information. In related links you can find another script which has includes more functionality and you are able to retrieve more information from the remote computers or servers. Check it out you might find it interesting too.
You can download the script here or copy it from below.
Hope you like it. If you have any questions or anything else please let me know in the comments below.
- Test-Connection – Microsoft Docs
- Get-WmiObject – Microsoft Docs
- Write-Host – Microsoft Docs
- Write-Output – Microsoft Docs
- How to get remote system information â€“ Part 1
- How to get remote system information â€“ Part 2
- How to get remote system information â€“ Part 3
Solution / Script:
<# .SYNOPSIS Name: Get-PCInfo.ps1 The purpose of this script is to retrieve basic information of a PC. .DESCRIPTION This is a simple script to retrieve basic information of domain joined computers. It will gather hardware specifications and Operating System and present them on the screen. .RELATED LINKS