Learn Windows CMD and PowerShell Easily – With Examples & Screenshots

Windows CMD vs PowerShell complete beginner guide

Windows CMD and PowerShell complete guide for beginners

Do you know how professionals arrange system, troubleshoot network or do task without touching the mouse? It is because of command-line tools, so let’s understand the theory of command-line tools in windows.

In the blog, we will learn deeply about both command-line tools, CMD or PowerShell. We will deeply explore both CLIs, their functions, commands and difference between CMD and PowerShell, also how it is different from GUI.

What is command line Interface (CLI)?

Windows basically have two modes, GUI and CLI. GUI stand for (graphical user interface) where user interact with system using icons, mouse and visual menus. However CLI stands for (command line interface) which is a text based interface instead of clicking items, you can directly type commands for performing tasks. CLI is most fast and powerful, especially for system tasks.

CLI have two tools in windows.

  • Command prompt(CMD)
  • PowerShell

Let’s understand both tools in detail.

Command Prompt(CMD)

Command Prompt is traditional command-line tool. It is used in old versions of windows and envelop from MS-DOS. It is mostly used for system administration, file system management, network troubleshooting and running batch script etc.

You can open command prompt in different ways, in start menu, search, command prompt or you can also run command prompt as administrator.

In the interface it has black screen with white text.

Basic Files commands

Here are some command that used on daily base work. We use these command to manage file and folders.

·        Dir

Dir command shows the list of all fie and folder inside a folder. Which include files names, folders name, date and size.

Basic file and folder listing using DIR command in Windows Command Prompt

·        Cd

Cd command means to change the folder. If I type some folder name (documents) after type cd, its mean I want to open that (documents) folder.

If I type cd .. Its means I want to go back to the pervious folder.

Using CD command to change directory in Windows Command Prompt

·        Mkdir

Mkdir commands mean to make a new folder. I type (mkdir testfolder), which means I’m going to make a new folder named TestFolder.

Creating a new folder using MKDIR command in Windows CMD

·        Rmdir

Rmdir command means to delete a folder. I’m going to type (rmdir TestFolder), means I’m going to delete that folder which named TestFolder.

Deleting a folder using RMDIR command in Windows Command Prompt

·        Del

Del command is used to delete a file permanently. For example I type (del file.txt), men sim going to delete file presently which named file.txt.

Deleting a file using DEL command in Windows Command Prompt

System and networking commands

System commands

As we explore earlier, Process & services in Windows Powershell allows user to view and manage all the running process of system using Get process and stop process.

·        Tasklist or Taskkill

Tasklist means running process, it shows all the list of programs that running in the system right now. Shows processes names, PID, and memory usage.

Windows CMD tasklist command showing running processes

Taskkill means to stop the process, for example you are using notepad in your system, taskkill forcefully stop or close your notepad.

CMD taskkill command stopping notepad process

·        System info

Systeminfo command shows the operating system version, Ram, process, system boot time and networking details.

Windows CMD systeminfo output showing OS and hardware info 

Networking commands

·        Ipconfig

Ipconfig shows the Ip address, subnet mask and default gateway.

Windows CMD ipconfig command output showing IP address and network configuration

·        Ping or tracert

Ping command checks if the internet connection are working properly or not also shows the packet send/ receive.

Tracert tells the route of data packets.

Windows CMD ping and tracert command output showing network connectivity and route to google.com

Some advance concepts of CMD

These are some advanced concepts of CMD.

Environment Variable: these are special shortcuts of system which store the important path and information of computer.

Batch Files: It is a script in which you have multiple commands. Instead of typing commands again & again, you can use that batch files.

Redirection: Redirection means save the result of command as a file instead of view on screen.

Pipes: it is a sign of pipe (|), which gives a command result to another command.

Admin Mode: some commands are run by system setting, which needs administrator permission for run.

Windows PowerShell

PowerShell is an advance or modern version of CMD, it is object- based and supports advanced scripting, automation and administration. It deeply integrates with windows. PowerShell is built on .NET framework. You can easily filter, sort and modify data in PowerShell.

In the interface is has default blue screen, you can type command but the output is object-based.

PowerShell commands (Cmdlets)

Basic Cmdlets commands

·        Get-ChildItem

This command shows all the files and subfolders. Equivalent to (dir) command of CMD.

·        New-Item test.txt

It create new file and folder, for example I make (test.txt).

·        Remove-Item test.txt

It delete file and folders.

·        Set-Location Desktop

This command change the working folder. Equivalent to (cd desktop ) command of CMD.

Understanding FileSystem structure of helps you to perfectly and efficiently using commands like Get child-Item and Set-Location.

PowerShell Get-ChildItem command showing all files and folders in the current directory

PowerShell commands showing New-Item to create a file, Remove-Item to delete a file, and Set-Location to change directory

Some concepts of PowerShell

These concepts include:

Object-based output: CMD gives text output, but PowerShell gives object output which makes data processing easy.

Pipeline: it is a pipe sign (|), which gives command (cmdlet) output to another command.

Execution policy: it a security rule which gives permission for script.

PowerShell scripting

  • Script are save in .ps1 named file.
  • Variables which are $name = "Work"
  • Loops for and for each
  • Conditional if and else

These script are shown to those processes which takes CPU more than 100

PowerShell deeply contacts with Window Internal Components, Advanced automation and system management.

Comparison btw CMD vs PowerShell

Windows CMD and PowerShell Side-by-Side ComparisonWindows CMD and PowerShell Side-by-Side Comparison

Real life examples

Let’s check how CMD and PowerShell help us in our real life daily tasks.

Here are some examples:

File & Folder Management

You can manage your files and folder easily with the help of CMD and PowerShell. You can create or delete folders and files, copy data from one location to another also move large number of files at once.

System Monitoring

Booth CMD and PowerShell helps user to monitor system resources regularly. You can check the status of each process, is it running, how much space they use, each n everything.

Network Troubleshooting

If your internet is slow or not working, you can use both CMD and PowerShell to diagnose the internet and network problems, check IP address, test internet connectivity etc.

Process Management

With thee help pf CMD and PowerShell you can view all the active program running on your computer, you can freeze them if they use more resources or you can also stop those using commands.

Task Automation

Automation is the biggest advantage of PowerShell. In automation you can create script that automatically perform task like backup of files, cleaning temporary data, and making reports and restart services.

Server administration

System administrators use PowerShell to manage multiple computers and servers remotely. That restart services, managing users, configure settings remotely without any physical access.

Security and permission management

With the help pf PowerShell administrator’s mange user accounts, set permissions, control services etc.

 

Some Interview questions to remember

Define Command Line Interface (CLI)?          

Answer:
CLI stands for (command line interface) which is a text based interface instead of clicking items, you can directly type commands for performing tasks. CLI is most fast and powerful, especially for system tasks.

Define concept of Command Prompt?

Answer:
C
ommand Prompt is traditional command-line tool. It is used in old versions of windows and envelop from MS-DOS. It is mostly used for system administration, file system management, network troubleshooting and running batch script etc.

Do you know how to open Command Prompt in Windows operating system?

Answer:

You can open command prompt in different ways.

Go to start menu, search, and find command prompt.

Tell us some commonly used CMD commands?

Answer:
These are some common CMD commands:

  • dir – which Displays files and folders
  • cd – that Changes directory
  • mkdir you can Creates a new folder
  • ipconfig – it Shows network configuration
  • ping – Tests network connectivity easily
  • tasklist – Displays all running processes

Define batch file?

Answer:
It is a script in which you have multiple commands. Instead of typing commands again & again, you can use that batch files.

Define concept of Windows PowerShell?

Answer:
Windows PowerShell
is an advance or modern version of CMD, it is object- based and supports advanced scripting, automation and administration.

Will you tell the difference between PowerShell and CMD?

Answer:
CMD
is traditional command-line tool. It is used in old versions of windows and envelop from MS-DOS. While PowerShell is an advance or modern version of CMD, it is object- based and supports advanced scripting, automation and administration.

Evaluate PowerShell pipeline?

Answer:
The pipeline
is a sign of pipe (|), which gives a command result to another command. This makes data processing and filter easily.

Define concept of Execution Policy in PowerShell?

Answer:
Execution Policy is a security feature in PowerShell
which gives permission for script.

Do you know why PowerShell considered more powerful than CMD?

Answer:
PowerShell is more powerful tool because it supports object-based output, advanced scripting, automation, remote management, and integration with the help of .NET framework. It is basically designed for system administration tasks.

Define redirection in CMD?

Answer:
R
edirection means save the result of command as a file instead of view on screen.

Tell some real-life uses of CMD and PowerShell?

Answer:

  • File & directory management
  • Network troubleshoot
  • Monitor system
  • Task Automation
  • Security & Server administration

Conclusion

In today digital world understanding of command-line is a valuable technical skill. Windows both CLIs Command prompt and PowerShell are powerful tools.CMD is fast and good for basic operations while PowerShell is modern and advanced. If you have interest in IT, cybersecurity, DevOps, networking etc. Then understand the concept of CLIs is highly recommended by practicing Commands, experiments with scripts, understand the logic of command-line will help you to become confident technical professional.

Comments

Popular posts from this blog

BIOS and Booting Process Explained – Complete Guide for Beginner

Processes & Services: Complete Guide for Beginners

What is a Virtual Machine? Complete Guide For Beginners