HomeHowTo › Retrieving System Information via Command Line on Windows

Retrieving System Information via Command Line on Windows

In Windows operating systems there’s a command-line utility called Windows Management Instrumentation Command-Line (WMIC) which allows you to retrieve plenty of system and hardware information. In this article I’ll show you some exemplary commands.


1. Basic Usage

To get a list of switches and aliases, type:

wmic /?

The /? switch can be appended to any command in order to get further information about the available options.
Basically, to get system information, you just need to append an alias name to the wmic command, i.e.:

wmic baseboard
wmic cpu
wmic memorychip


2. List Output

The output however is quite confusing, so you might wanna prefer the list option. Useful list formats are “full” and “brief”. Since the “brief” one comes out as a table, you can append the /format switch to get a list instead.

wmic baseboard list full
wmic cpu list full
wmic memorychip list brief /format:list

You can copy the output directly into the clipboard by piping it into clip:

wmic baseboard list brief /format:list | clip


3. Exporting Formatted Output

It’s also possible to export the output in formats like CSV or HTML. To get a list of available formats, type:

wmic baseboard list /format /?

Then you can export the output like this:

wmic baseboard list /format:list > C:\output.txt
wmic cpu list /format:csv > C:\output.csv
wmic memorychip list /format:hform > C:\output.html


4. Fix the “Invalid XSL format (or) file name” Error

If you use the /format switch you might encounter this error. This happens if your system’s locale setting differs from the language the operating system was originally installed in. Unfortunately the /locale switch does not seem to work so you have to manually fix the problem:

  • In Windows Explorer go to: %WINDIR%\System32\wbem\en-US (or your corresponding locale folder)
  • Search for: *.xsl
  • You should find 5 files; select and copy these
  • Go to: %WINDIR%\System32\wbem\
  • Create a new folder for your locale (i.e. “de-DE” for Germany)
  • Go into the new folder and paste the files


5. Retrieve Only Chosen Attributes

To not get the full list of attributes but only a few, type:

wmic baseboard get manufacturer,product,version /format:list

To find out the available attributes for an alias, type:

wmic nic get /?


6. Determine the Model Name of a Notebook

wmic csproduct list full


7. Using the Powershell

With the wmic command it does not seem to be possible to get information about the video card. This however does work with the powershell and the following command:

Get-WmiObject Win32_Videocontroller

Some classes don’t output everything by default. In this case do:

Get-WmiObject Win32_OperatingSystem | Format-List *

To show only chosen information:

Get-WmiObject Win32_Videocontroller | Select-Object -Property Caption,Description,Name,Videoprocessor | Format-List *

To get a list of all available classes, type:

Get-WmiObject -List -Namespace "root\cimv2" | Sort

Some examples:

Get-WmiObject Win32_ComputerSystem
Get-WmiObject Win32_BaseBoard
Get-WmiObject Win32_Bios
Get-WmiObject Win32_Processor
Get-WmiObject Win32_PhysicalMemory
Get-WmiObject Win32_DiskDrive
Get-WmiObject Win32_LogicalDisk
Get-WmiObject Win32_NetworkAdapter
Get-WmiObject Win32_OperatingSystem

By changing the namespace (root\cimv2 is the default), you get access to additional classes.
To get a list of available namespaces, type:

Get-WmiObject -Class __Namespace -Namespace root | Format-Table name

To search for specific values, you can perform an SQL-like query:

Get-WmiObject -Query "Select * From Win32_Service Where State='Running'" | Format-Table Name,Description,ProcessId

Some classes provide methods that can be executed. To find out the available methods, enter the first command. To execute a method, append it to a Query:

Get-WmiObject Win32_Service | Get-Member -MemberType Method
(Get-WmiObject -Query "Select * From Win32_Service Where Name='wuauserv'").StopService()
(Get-WmiObject -Query "Select * From Win32_Service Where Name='wuauserv'").StartService()

22 Comments.[ Leave a comment ]

  1. How would I set up a command to spit out Sensor information, I tried the “temperature” command but it says “no instances listed” – Can you show me how to set that up?

  2. I can’t get it to work either. On my netbook I’m getting “no instances listed” and on my desktop it shows me three sensors but no values. As I understand it, the temperature classes do not work on most computers because WMI can’t query the sensors due to interface incompatibilities.

  3. Ok, thanx. What I need is some kind of command line program that can read the sensor info and spit it out remotely, it MUST be a command line version. I’ve looked into the shareware that’s on Hiren’s Boot Disk, but there is a lot of stuff and I didn’t see anything that could spit out the results in text.

    I believe it is a Windows “8” server, so that could be another problem. Is there any way to poll a server remotely to pull up the sensor data? I suggested installing something like Aida64 and then telling to to generate a daily report, or maybe even several daily reports. If Aida64 can read the sensor data or at least some of it, why can’t there be a command line program to spit out just the current sensor values?

    Thank you much.

  4. The problem is that most mainboards/sensors don’t provide a WMI interface, which results in Windows not being able to query those. Third-party tools like Aida, Everest and HWiNFO probably use their own routines or libraries from the hardware manufacturers to query the hardware directly.

    Professional server vendors, however, might supply special drivers or system apps for their servers which provide enhanced functionality in this regard. I don’t have any experience with that, though.

    But I found a possibility to get all sensor data using the PowerShell with a third-party tool running in the background. The tool is called “Open Hardware Monitor”. It is a graphical tool with two cool additional features: a built-in webserver which makes the sensor data available via webbrowser and a WMI interface that can be queried by the PowerShell.

    With the following command you get the current value of every temperature sensor:

    Get-WmiObject -Namespace “Root\OpenHardwareMonitor” -Query “SELECT * FROM Sensor WHERE Sensortype=’Temperature'” | Format-Table Identifier,Value

    To get periodic reports you can create a little PowerShell script (.ps1 file) and have that executed by the Windows Task Scheduler, i.e.:

    Get-Date >> sensordata.txt
    Get-WmiObject -Namespace “Root\OpenHardwareMonitor” -Query “SELECT * FROM Sensor WHERE Sensortype=’Temperature'” | Format-Table Identifier,Value >> sensordata.txt
    Write-Output “================================================================================” >> sensordata.txt

    Executing PowerShell Scripts might be disabled by default. You can activate it by issuing the following command in a PowerShell (needs administrative privileges!):

    Set-ExecutionPolicy unrestricted

    I hope that this solution is useful for you.

  5. The Openhardware program works great, I can open the web browser, I entered your commands in Powershell, it spat this back out at me:

    [code]Get-WmiObject : Invalid query “SELECT * FROM Sensor WHERE Sensortype=’Temperature’”
    At line:1 char:1
    + Get-WmiObject -Namespace “Root\OpenHardwareMonitor” -Query “SELECT * FROM Sensor …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand[/code]

    If the command you gave was a structure for a tailored command I would have to make, I am afraid I don’t understand what values I am supposed to put in these fields, if you can just point me in the right direction I can probably figure it out.

    For example, whee it says -namespace do I put the address and port of my machine in there? I am not entering something correctly, from what I understand it says I am not using “Select” properly

  6. You can use the command as is, no substitutions necessary. The problem in this case is that WordPress alters the quotation marks. If you copy&paste the code, you have to fix the ” and ‘ before you hit Enter.

  7. Actually I love this program – I may start using it instead of Aida64.

    Damn – So its the way the code is being transferred? Do you have a pastebin acct you can copy that to?

    How is the ” and ” supposed to look, just replace those with the regular ” and ‘ characters? Thanx much.

  8. I don’t have a pastebin, but as you said, just removing the ” and ‘ and replacing them with the regular ones will do the trick.

  9. OH HECK YES! It worked.

    Now, to figure out a way to invoke that remotely, which I am sure is no problem. Great thanx a lot, I was researching this for a friend, he was stumped, we all were stumped. Thank you big time!

  10. So, I save the last commands as a script – Do I do that by just saving it to Notepad with a “psi” extension or is there some other method – I’ve never used powershell before, even though its been in all of my computers for years. heh.

    This whole thing about saving the script and invoking it as a task, that’s what we would need to do, that way the sensordata.txt file can just be retrieved periodically. Anyway I think I got enough here to keep me busy, thanx a million.

  11. Alright, I found the Powershell ISE program, I tried to allow scripts but it says I got no permissions to access some reg entry. I elevated permissions to the reg entry, whammo, made a script. This is great I love it! Now I’ll be fiddling with it all day haha

  12. Cool, I’m glad that I was able to help.

    Get-WmiObject has switches for remote execution: -ComputerName -Credential and -Impersonate

    In my home network (no domain, no server) it didn’t work, though.

  13. I know, but I set up port 8085 in my router and in my firewalls, I was able to pull the page right up on my iPhone through safari.

    If you r router is like mine and it assigns IP addresses randomly, then you can forward the port on every address in the range, that way, the command will work for whatever system is running Open Hardware. If there are more than one instances, then I’d run each other machine on subsequent ports, like 8086, 8087 etc. and id set up forwarding on those ports for all IPs.

  14. Port Range Triggering – If you have an array of machines running Open Hardware, you can set the port ranges for forwarding and triggering, for the whole network. That seems to be the way to do it. I’ll set up more machines with Open Hardware and see if it pulls up all of the results.

  15. Forwarding all used ports to all IP addresses is not a good practice in my opinion. I’d suggest to set static IP addresses and forward each port to the corresponding address.

    Port Triggering doesn’t make sense in this scenario as it only forwards a port after an outgoing connection to a certain port (trigger) has been established.

  16. It was the only way I could get my router to pass my direct IP address request to my system. I suppose there are other ways to set up a permanent static IP, I was trying to set up a dynamic DNS account for my home network, but I think the service swallowed my email address for the sake of adding it to spammers, I didnt get the email it was supposed to send, I got 25 new spams instead.

  17. If your router doesn’t have a static IP address, Dynamic DNS is the only thing you can do to access it from a remote location. The local computers behind the router however should have static IPs if you use Port Forwarding.

  18. My Old Router – An old original linksys G WiFi – I would assign the IPs and they would stay forever the same. I “updated” to a WRT style router and it has been a pain in the arse. You have to build a network one PC at a time, and then it mixes the IP addys around all the time.

  19. Hmm? I don’t get how you manage your IP addresses.

    I would configure static IP addresses on the stationary computers and use DHCP automatic configuration for mobile devices. The router itself gets its IP from the ISP.

    I have been using DD-WRT for more than 2 years now and I’m very happy with it 😉

  20. Yah, that’s my problem, my particular router is “immune” to DD-WRT. It’s a WRT110.

    Which is the only one that can’t use DD-WRT, which in itself is crazy cos its the original WRT router. I use it cos it’s N, and I was able to get my iPhone Wifi to run as “N” with it.

  21. I am lookin through your blog, and I see you have all kinds of information. One of the things I don’t get is PHP, so don’t be surprised when I pop up in another area. I’ve got you bookmarked now, I see that this is actually an archived blog hahaha. I’m glad I found it, I am still fooling around with WMIC. You may know a friend of mine, Mike Burns, another Musician and Computer Genius from Germany, I’m jealous of the guy cos even in 2001 he had a massive Pro Tools HD system with dual cinematic display. And I’m still struggling with a Digi 001 on XP, cos I cant get the plugins for MACOS 10.3.9

  22. Hey, Nice article here. Fixed my problem with invalid XSL error. Also shed some light in using wmic.

Leave a Comment