What is PowerShell – Overview

Introduction

Microsoft releases PowerShell on 14 November 2006 for commercial use. It is built on the .Net framework and supports object-oriented programming methodology.

Earlier in each release of window operation system, there is one Command-line interpret (CLI) like MSDOS which is used for also basic operations but it not capable to perform GUI operation like if you need to create a windows application form that is not possible using MSDOS so Microsoft has introduced PowerShell which support command line task as well as GUI operations.

What is PowerShell?

PowerShell is a scripting language build on top of .net framework and it is used to configure or automate tasks. It is an open-source language that means you do not need to pay any license fees to use PowerShell. System Administrators, IT Professionals anyone can use the PowerShell to perform or automate tasks.

I give you one example so that you can understand suppose you want to remove one windows 10 app from your production environment and being a developer you do not have access to production. So you write a PowerShell script and send the same to system administrators who generally have access to upper environments they will execute the script so I am team everyone can use the PowerShell for configuration change and to automate the task.

Why use PowerShell

There are many factors, which you can consider where PowerShell is helpful –

  1. It is open-source and preinstalled with all latest windows operating systems.
  2. It supports object-oriented programming where you can create Class, functions, variable, etc. to perform an action on the server.
  3. Being a powerful shell it has access to the file system so using PowerShell you can copy, move, update, and delete files in a file system.
  4. Using PowerShell you can automate tasks by writes script and later schedule those scripts using any window service or task scheduler.
  5. It provides GUI which helps you to write and debug script.

How to Launch PowerShell

Just go to windows and search for PowerShell here you will find the “Windows PowerShell” and “Windows PowerShell ISE” options. So if you have to run command then simply open the “Windows PowerShell” command-line editor as administrator and run the command but if you want to create a new script or modify the existing script or debug the script then open the “Windows PowerShell ISE”  GUI editor you can use.

How to Launch PowerShell

How to identify the PowerShell script

All files, which have .ps1 extension, are called PowerShell script and it has been executed on the PowerShell command-line interface.

How to execute PowerShell script

There are two ways to execute the PowerShell script.

  1. Direct from PowerShell command line – When you have one or two liner commands or script that method is good. Just paste it on the command line and hit enter to execute the script.
  2. Execute script file – Suppose you have a requirement where you need to write a long script, which has 100 lines then write the script and save the file with the “.ps1” extension. Then run this file from the command-line editor.

Go to that path in PowerShell command line where you script saved then press the first character of the file name and press tab then enter to execute the script.

how to execute powershell script

PowerShell Version

Microsoft released several major and minor versions of PowerShell and the latest PowerShell version at the time I am writing is article is PowerShell 7. In each release, they have increased the no. of cmdlets to provide more flexibility to PowerShell users.

Version List –

1.Windows PowerShell 1.0

2.Windows PowerShell 2.0

3.Windows PowerShell 3.0

4.Windows PowerShell 4.0

5.Windows PowerShell 5.0

6.Windows PowerShell 5.1

7.PowerShell Core 6.0

8.PowerShell Core 6.1

9.PowerShell Core 6.2

10.PowerShell 7

How to check PowerShell version

Open PowerShell command-line editor and run below commands to check which version of PowerShell is installed on your machine.

  1. Get-Host – Type Get-Host command and press enter to get the PowerShell version.

how to get powershell verison

2. $PSVersionTable – Type $PSVersionTable command and hit enter.

get powershell version

So on my machine PowerShell version, 5.1 is installed.

This is a very simple right. You do not need to do much to learn PowerShell just you need basic programming skills so that you can write the complex script to perform different operations.

Powershell provides a bunch of commands that are called cmdlets. Using these cmdlet you can perform work on different tasks. In upcoming tutorials, we understand PowerShell cmdlet that actually you need to learn to works on PowerShell.

I hope now you have basic PowerShell understand that will help you to understand other lessons as well.