15 Useful Windows CMD Commands Every IT Admin Should Know

  • Windows
  • Command Prompt
  • Beginner
  • 11 min read
15 Useful Windows CMD Commands Every IT Admin Should Know

These 15 Windows CMD commands answer the questions a support engineer asks first: who is logged in, how long the PC has been running, whether the disk is healthy, and whether Windows is activated. Every command below has an example you can copy and the options you are most likely to need.

Last updated: November 2026

In short

  • All 15 commands are built into Windows 10 and Windows 11. Nothing needs to be installed.
  • Most of them only read information, so they are safe to try.
  • Three need an administrator prompt and some care: chkdsk with repair options, powercfg /energy, and netsh wlan export profile key=clear. The last one writes Wi-Fi passwords to disk as readable text.

How to Open Command Prompt

Press Win + R, type cmd and press Enter. For the commands marked “admin” below, open the Start menu, type cmd, and choose Run as administrator.

The commands also work in PowerShell and Windows Terminal, with one exception that is explained under fc. Microsoft documents every option in its Windows commands reference.

All 15 Windows CMD Commands at a Glance

C:\> help –top 15

  1. whoamiShows the current user name
  2. query userShows who is logged in
  3. net userLists the local user accounts
  4. winverShows the Windows version and build
  5. net stats workstationShows when the PC last started
  6. slmgr /xprShows the Windows activation status
  7. driverqueryLists the installed drivers
  8. getmacShows the MAC address of each adapter
  9. netsh wlan export profile key=clearExports saved Wi-Fi profiles
  10. chkdskScans a disk for errors
  11. diskmgmt.mscOpens Disk Management
  12. fc file1.txt file2.txtCompares two files
  13. resmonOpens Resource Monitor
  14. powercfg /energyCreates a power efficiency report
  15. devmgmt.mscOpens Device Manager

Tap a command to jump to it. “admin” = run Command Prompt as administrator.

Who Is Using This PC?

01 whoami: Display the Current User Name

  • Read-only

whoami prints the account you are working as, in the form computer\user or domain\user. It is the quickest way to confirm which account a prompt or a script is running under.

cmd
whoami
cmd
whoami /groups
cmd
whoami /priv
  • /groups lists the groups you belong to. Use it to check whether a user is really in the Administrators group.
  • /priv lists your privileges. An administrator prompt shows a much longer list than a normal one.
  • /all shows everything at once, including the account’s security identifier (SID).

02 query user: Show Logged-in Users

  • Read-only
  • Pro and Server editions

query user lists every user with a session on the machine, with the session name, the state (active or disconnected), the idle time and the logon time. It is most useful on a server that several people reach by Remote Desktop.

cmd
query user
cmd
query user /server:SERVER01

The second command asks another computer, here one named SERVER01. The short form of the command is quser.

Not on Home editions

This command comes with the Pro, Enterprise, Education and Server editions. On Windows Home you will normally see “not recognized as an internal or external command”.

03 net user: List All User Accounts

  • Read-only as shown

net user lists the local accounts on the PC. Add an account name to see its details: when the password was last set, when it expires, the last logon, and the groups the account belongs to.

cmd
net user
cmd
net user Administrator
cmd
net user jsmith /domain

With /domain, the question goes to the domain controller, not the local PC. That makes it a fast check when a user says “my password stopped working”: look at the “Password expires” and “Account active” lines.

Reading is safe, changing is not

The same command can create accounts and reset passwords when it is given more options in an administrator prompt. The three examples above only read information.

What Is This Machine?

04 winver: Show Windows Version Information

  • Opens a window

winver opens the small “About Windows” window. It shows the edition, the version (for example 24H2) and the OS build number. Ask for this first when someone reports a problem, because many bugs and fixes belong to one specific build.

cmd
winver
cmd
ver
cmd
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

ver prints the build number as text that you can paste into a ticket. The systeminfo line adds the edition name, such as “Microsoft Windows 11 Pro”.

05 net stats workstation: Check System Uptime

  • Read-only

This command prints network statistics. For uptime, read the line near the top that starts with Statistics since and is followed by a date and time. That is when the Workstation service started, which is normally a few seconds after Windows started.

cmd
net stats workstation
cmd
net stats workstation | find "since"

The second command shows only the line you want. For the exact boot time, use systeminfo | find "System Boot Time".

Why uptime can be weeks

Windows 10 and 11 use Fast Startup by default. With it, Shut down saves part of the system to disk and does not count as a fresh start. Only Restart does. So when a user says “I shut it down every night” and the uptime is 30 days, both can be true.

06 slmgr /xpr: Check Windows Activation Status

  • Read-only
  • Opens a window

slmgr /xpr opens a small window that says either “The machine is permanently activated” or the date when the current activation ends. Volume licenses activated through a company KMS server show an end date, because they are valid for 180 days and renew automatically.

cmd
slmgr /xpr
cmd
slmgr /dli
cmd
cscript //nologo %windir%\system32\slmgr.vbs /xpr
  • /dli shows the license type and part of the product key.
  • The third command prints the answer in the console instead of a pop-up window, which is what you want in a script or a remote session.

07 driverquery: List Installed Drivers

  • Read-only

driverquery lists every installed device driver with its name, type and link date. It is helpful after a blue screen that names a driver file, or when you need to compare two machines.

cmd
driverquery
cmd
driverquery /v
cmd
driverquery /si
cmd
driverquery /fo csv > drivers.csv
  • /v adds detail, such as whether each driver is running and where its file is.
  • /si shows whether each driver is digitally signed, and who made it.
  • The last command saves the list as a CSV file that opens in Excel.

Network

08 getmac: Show the MAC Address of a Network Adapter

  • Read-only

A MAC address is the hardware address of a network adapter. You need it to reserve an IP address in DHCP, to add a device to a Wi-Fi allow list, or to find a device in a switch’s address table.

cmd
getmac
cmd
getmac /v /fo list

Plain getmac prints the addresses with a long device path that is hard to read. The second form adds the connection name (for example “Wi-Fi” or “Ethernet”) and the adapter model, so you can tell which address belongs to which adapter. An adapter that is not connected shows “Media disconnected”.

09 netsh wlan export profile key=clear: Export Saved Wi-Fi Profiles

  • Admin prompt
  • Writes passwords to disk

Windows remembers every Wi-Fi network the PC has joined. This command writes each one to an XML file, one file per network. It is the standard way to move Wi-Fi settings to a new PC.

cmd (admin)
mkdir C:\wifi-backup
cmd (admin)
netsh wlan export profile folder=C:\wifi-backup key=clear
cmd (admin)
netsh wlan add profile filename="C:\wifi-backup\Wi-Fi-Office.xml"
  • Without folder=, the files are written to the folder you are in. The folder must already exist.
  • key=clear writes each password as readable text, inside the keyMaterial element of the file. It only does this in an administrator prompt. Without it, the password is stored encrypted and the file is only usable on the same PC.
  • The third command imports one file on the new PC. The file name here is an example.

To read one forgotten password without creating files, use netsh wlan show profile name="Office" key=clear and look at the “Key Content” line.

These files contain passwords

Anyone who can open the exported files can read your Wi-Fi passwords. Do not put them on a shared drive or send them by email. Import them on the new PC, then delete them. Run this only on computers and networks you are responsible for.

Disks and Files

10 chkdsk: Scan a Disk for Errors

  • Admin prompt
  • /f and /r change the disk

chkdsk checks the file system on a drive. With no options it only reports what it finds, so you can run it at any time.

cmd (admin)
chkdsk C:
cmd (admin)
chkdsk D: /f
cmd (admin)
chkdsk D: /r
  • /f fixes the file system errors it finds.
  • /r also reads the whole drive to find bad sectors and recover what it can. It includes /f.

A repair needs the drive to itself. For the Windows drive, chkdsk offers to run at the next restart. Answer Y and restart when the user can wait.

Back up first, and plan the time

On a large hard disk, /r can run for several hours, and the PC cannot be used until it finishes. If you suspect the disk is failing, copy the important data off it before you run a repair.

11 diskmgmt.msc: Open Disk Management

  • Opens a window
  • Admin to make changes

This opens the Disk Management console, which shows every disk and its partitions as a picture. Use it to bring a new disk online, create or format a volume, change a drive letter, or extend and shrink a partition.

cmd (admin)
diskmgmt.msc

It is the first place to look when a new or external drive is connected but does not appear in File Explorer. Usually the disk is there with no drive letter, or it is not yet initialized.

12 fc: Compare Two Files

  • Read-only

fc (file compare) shows the lines that differ between two files. It is good for a quick answer to “what changed in this configuration file?”

cmd
fc file1.txt file2.txt
cmd
fc /n old.conf new.conf
cmd
fc /b image1.iso image2.iso
  • /n shows line numbers.
  • /c ignores the difference between capital and small letters.
  • /b compares byte by byte, for files that are not text.

If the files are the same, the answer is “FC: no differences encountered”.

In PowerShell, type fc.exe

In PowerShell, fc is a short name for a different command (Format-Custom), so the result looks wrong. Type fc.exe file1.txt file2.txt to get the file comparison.

Performance, Power and Hardware

13 resmon: Open Resource Monitor

  • Opens a window

Resource Monitor shows more than Task Manager. It has five tabs: Overview, CPU, Memory, Disk and Network.

cmd
resmon

It can answer these three questions:

  • What is keeping the disk at 100%? The Disk tab lists the files being read and written, with the process behind each one.
  • Which program is using the network? The Network tab shows each process with the addresses it is talking to.
  • Which program has this file locked? On the CPU tab, type the file name in the “Associated Handles” search box.

14 powercfg /energy: Generate a Power Efficiency Report

  • Admin prompt
  • Takes 60 seconds

This command watches the PC for 60 seconds, then writes a report named energy-report.html. The report lists errors and warnings: devices that stop the PC from sleeping, USB devices that never suspend, and processes that keep the processor busy.

cmd (admin)
powercfg /energy /output C:\Temp\energy-report.html
cmd (admin)
powercfg /batteryreport /output C:\Temp\battery-report.html
  • Close other programs and do not touch the PC during the 60 seconds, so the report shows the PC at rest. The folder in /output must already exist.
  • Without /output, the report is written to the current folder. In an administrator prompt that is normally C:\Windows\System32.
  • On a laptop, the second command creates a battery report. Compare “Design capacity” with “Full charge capacity” to see how worn the battery is.

15 devmgmt.msc: Open Device Manager

  • Opens a window
  • Admin to make changes

Device Manager lists every piece of hardware Windows has found. A yellow warning mark means a device has a problem, most often a missing or wrong driver. Open the device, and the Device status box gives an error code you can search for.

cmd
devmgmt.msc
cmd
pnputil /enum-devices /problem

The second command lists only the devices that have a problem, as text, without opening a window. It works on Windows 10 version 1903 and later.

From the Driver tab you can update a driver, or use Roll Back Driver when a problem started right after an update.

A Five-Minute Health Check

When a user says their PC “is slow” or “acts strange”, run these commands in this order.

  1. Run whoami and winver. You now know the account and the exact Windows build.

  2. Run net stats workstation | find "since". If the PC has been up for weeks, restart it before anything else.

  3. Open resmon and look for one process that holds the CPU, the memory or the disk.

  4. Run chkdsk C: with no options. If it reports problems, back up, then plan a repair.

  5. Open devmgmt.msc and look for yellow warning marks.

  6. Save the facts for your ticket: driverquery /fo csv > drivers.csv and getmac /v /fo list.

Frequently Asked Questions

Do these commands work on both Windows 10 and Windows 11?

Yes, they ship with both. The exception is query user, which Home editions normally do not include.

Which of these commands can change my system?

chkdsk with /f or /r repairs the disk, and netsh wlan export profile creates files that hold passwords. Disk Management and Device Manager can make large changes, but only when you choose an action inside them. The rest only show information.

Why do I get “Access is denied”?

The command needs an administrator prompt. Open the Start menu, type cmd, and choose Run as administrator.

Can I save the output of a command to a file?

Yes. Add > file.txt to the end, for example net user > users.txt. Use >> to add to a file without replacing what is in it.

Key Takeaways

  • whoami, winver and the uptime line from net stats workstation give you the account, the build and the time since the last start.
  • With Fast Startup on, only Restart gives Windows a fresh start; Shut down does not.
  • chkdsk with no options only reports. Back up before you add /f or /r.
  • Exported Wi-Fi profiles hold readable passwords. Delete them once the new PC has them.
  • In PowerShell, type fc.exe, because plain fc runs Format-Custom there.

Related guides on infotechtu.com

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top