Although PowerShell has made progress over the last few years as the preferred command line tool, I find that knowledge of the original command line is still very valuable. You can use the command line to quickly get system information or write batch scripts to automate simple tasks.
Most commands can be run as a regular user. But, as always, depending on what you are doing some commands may need to be run at an elevated prompt. To see all available commands, type “help”. To see help about a specific command use “<command> /?”.
Navigate & Help
cd /d H: | Change drive to H: drive |
cd \ | Change directory to C:\ |
help | See all commands. |
<command> /? | Get help about command <command>. |
User Information
net user administrator /active:yes | Enable the hidden Administrator acct (run cmd as admin). |
gpupdate /force | Update the user’s group policies. |
net user username1 /domain | Get current user details (last logon, passwd age, etc). |
gpresult /user <user1> /r | more | Get a list of the user’s domain groups. |
psloggedon \pcname or ip | See who is logged in (sys internals). |
net users | print a list of all system users. |
sc query | more | Display status of active services. |
net localgroup administrators | List all local administrators. |
net localgroup “remote desktop users” | List users allowed to login remotely. |
Folder & Files
dir | Display files in the current folder. |
cipher s:/<Folder name> | Check if a folder/file is encrypted. |
cipher /c | Display info on the encrypted file. |
mkdir | Make a Directory |
find or findstr “Find” | Find all lines with the word “joe”. |
del newfile.txt | Delete the file newfile.txt. |
move [source] [ target] | Move file to new location. |
fc /a monthly.txt sales.txt | Compare two text files. |
robocopy /s [src] [dst] | Copy directories except empty ones. |
System Information
msinfo32 | Launch the system info GUI. |
hostname | Display the name of the computer. |
wmic cpu get numberofcores, NumberOfLogicalProcessors | Display # of CPU cores and logical processors. |
wmic /node:10.10.56.10 bios get name, version | Display BIOS name & ver. from a remote PC. |
wmic os get caption, version | Display OS name and version. |
wmic computersystem get manufacturer, model | Display PC manufacturer and model. |
systeminfo <hostname> | find “OS Name” | Display the OS Name only. |
net share | List all files on the system that you are sharing. |
System Tasks
msconfig | Launch sys config GUI. Manage startup programs. |
taskkill | Kill running processes. |
shutdown /r | Shutdown and reboot the pc. |
mstsc /admin | Start an RDP session. |
tasklist | display running processes. |
wmic process get description, executablepath | display running executables. |
schtasks /query | more | Display scheduled tasks |
Networking
ping -a | Test network connectivity and resolve DNS. |
ipconfig /all | Displays current IPv4, DNS server name, and Gateway router IP, and other info. |
nslookup | Returns an IP address or a name. |
tracert <url> | Trace & displays path to reach an internet host. |
netstat | Check the UDP/TCP connections. ( See Article) |
route print | List routing table. |
arp -a | Get address resolution table. |
netsh | Change network setting, like whether to use DCHP (See below). |
nbstat | Display stats and current connections using NetBIOS over TCP/IP. |
How to Manually Set Your Networking
Run these commands at an elevated prompt.
Set a static IP
netsh interface ip set address name="Local Area Connection" static 192.168.0.1 255.255.255.0 192.168.0.254
Set DHCP from a static IP address
netsh interface ip set address name="Local Area Connection" source=dhcp
Set A Primary DNS Server To a static IP
netsh interface ip set dns name="Local Area Connection" static 192.168.0.250
Set the secondary DNS server to a static IP
netsh interface ip add dns name="Local Area Connection" 8.8.8.8 index=2
Set your DNS settings to be assigned dynamically
netsh interface ip set dnsservers name="Local Area Connection" source=dhcp