
Best PowerShell Tutorial | Quickstart – MUST-READ
Last updated on 30th May 2020, Blog, Tutorials
What is PowerShell?
Windows PowerShell is an object-oriented automation engine and scripting language. It is designed mainly for the system administrators. It helps IT, professionals, to control & automate the administration of the Window OS and other applications.It introduced some compelling new concepts that enable you to extend the knowledge you have gained and the scripts that you have created within the Windows Command Prompt and Windows Script Host environments.It combines the flexibility of scripting, command-line speed, and the power of a GUI-based admin tool. It allows you to solve problems efficiently by helping system admin to eliminate future manual labor hours. We will go through all the important aspects which you should know to learn PowerShell.
Why Use Powershell?
Here, are some important reason for using Powershell:
- Powershell offers a well-integrated command-line experience for the operation system
- PowerShell allows complete access to all of the types in the .NET framework
- Trusted by system administrators.
- PowerShell is a simple way to manipulate server and workstation components
- It’s geared toward system administrators by creating a more easy syntax
- PowerShell is more secure than running VBScript or other scripting languages
PowerShell History
PowerShell first version 1.0 was released in 2006. Today, PowerShell is at version 5.1.As the year and version went by, PowerShell’s capabilities and hosting environments grew significantly.
Let See Version wise History of Powershell:
- PowerShell version 1 supported the local administration of Windows Server 2003
- PowerShell 2.0 was integrated with Windows 7 and Windows Server 2008 R2. This version supports remoting and enhances the capabilities of PowerShell like transactions, background jobs, events, debugging, etc.
- PowerShell 3.0 was released as an internal part of the Windows management framework. It was installed on Windows 8 and Windows Server 2012. You can add and schedule jobs, session connectivity, automatic module loading, etc.
- PowerShell 4.0 was shipped with Windows 8.1 and Windows Server 2012 R2. In this version added support for desired state configuration, enhanced debugging, network diagnostics.
- PowerShell 5.0 was released as an internal part of Windows management framework 5. The features offered in this version are remote debugging, class definitions, .NET enumerations, etc.
Features of Powershell
- PowerShell Remoting: PowerShell allows scripts and cmdlets to be invoked on a remote machine.
- Background Jobs: It helps you to invoke a script or pipeline asynchronously. You can run your jobs either on the local machine or multiple remotely operated machines.
- Transactions: Enable cmdlet and allows developers to perform
- Evening: This command helps you to listen, forward, and act on management and system events.
- Network File Transfer: Powershell offers native support for prioritized, asynchronous, throttled, transfer of files between machines using the Background Intelligent Transfer Service (BITS) technology.
How to launch PowerShell
PowerShell is pre-installed in all latest versions of Windows. We need to launch PowerShell for that we need to follow the given steps:
Step 1) Search for PowerShell in Windows. Select and Click

Step 2) Powershell Window Opens

PowerShell Cmdlet
A cmdlet which is also called Command let is a lightweight command used in the Window base PowerShell environment. PowerShell invokes these cmdlets in the command prompt. You can create and invoke cmdlets commands using PowerShell APIS.
Cmdlet vs. Command:
Cmdlets are different from commands in other command-shell environments in the following manners −
- Cmdlets are .NET Framework class objects It can’t be executed separately
- Cmdlets can construct from as few as a dozen lines of code
- Parsing, output formatting, and error presentation are not handled by cmdlets
- Cmdlets process works on objects. So text stream and objects can’t be passed as output for pipelining
- Cmdlets are record-based as so it processes a single object at a time
Most of the PowerShell functionality comes from Cmd Let’s which is always in verb-noun format and not plural. Moreover, Cmdlet’s return objects are not text. A cmdlet is a series of commands, which is more than one line, stored in a text file with a .ps1 extension.
A cmdlet always consists of a verb and a noun, separated with a hyphen. Some of the verbs use for you to learn PowerShell is:
- Get — To get something
- Start — To run something
- Out — To output something
- Stop — To stop something that is running
- Set — To define something
- New — To create something
PowerShell commands:
Following is a list of important PowerShell Commands:
- Get-Help: Help about PowerShell commands and topics
Example: Display help information about the command Format-Table
- Get-Help Format-Table

- Get-Command: Get information about anything that can be invoked
Example: To generate a list of cmdlets, functions installed in your machine
- Get-Command

- Get-Service: Finds all cmdlets with the word ‘service’ in it.
Example: Get all services that begin with “vm”
- Get-Service “vm*”

- Get- Member: Show what can be done with an object
Example: Get members of the vm processes.
- Get-Service “vm*” | Get-Member

Other Commands:
- Get- Module: Shows packages of commands
- Get- Content: This cmdlet can take a file and process its contents and do something with it
- Get- get: Finds all cmdlets starting with the word ‘get-
Example: Create a Folder
- New-Item -Path ‘X:\ADMIN1’ -ItemType Directory
PowerShell Scripts:
Powershell scripts are stored in .ps1 file. By default, you can’t run a script by just double-clicking a file. This protects your system from accidental harm. To execute a script: right-click it and click “Run with PowerShell.”

Moreover, there is a policy which restricts script execution. You can see this policy by running the Get-ExecutionPolicy command.
You will get one of the following output:
- Restricted— No scripts are allowed. This is the default setting, so it will display the first time when you run the command.
- AllSigned— You can run scripts signed by a trusted developer. With the help of this setting, a script will ask for confirmation that you want to run it before executing.
- RemoteSigned— You can run your or scripts signed by a trusted developer.
- Unrestricted— You can run any script which you wants to run
Steps to Change Execution Policy
Step 1) Open an elevated PowerShell prompt. Right Click on PowerShell and “Run as Administrator”

Step 2) Enter the Following commands
- Get-ExecutionPolicy
- Set-execution policy unrestricted
- Enter Y in the prompt
- Get-ExecutionPolicy

First PowerShell Script
In a notepad write the following command
- Echo “Hello world…..”
PowerShell Scripts have an extension ps1. Save the file as FirstScript.ps1

In Powershell, call the script using the command
- & “X:\FirstScript.ps1”
What is PowerShell ISE?
The Windows PowerShell Integrated Scripting Environment(ISE) is the default editor for Windows PowerShell. In this ISE, you can run commands, writer test, and debug scripts in an in a window based GUI environment. You can do multiline editing, syntax coloring, tab completion, selective execution and lots of other things. Windows PowerShell ISE also allows you to run commands in a console pane. However, it also supports panes that you can use to simultaneously view the source code of your script and other tools which you can plug into the ISE.
You can even open up multiple script windows at the same time. This is specifically useful when you are debugging a script which uses functions defined in other scripts or modules.

The same script we created in notepad, can be created in ISE
- Paste code into the editor
- Save Script
- Use F5 to run the script
- Observe output in the console

Sample 2:
The following code will give the Free Virtual Memory in your machine
- Get-WmiObject -Class Win32_OperatingSystem –ComputerName localhost | Select-Object -Property CSName,FreeVirtualMemory

Advantages of using PowerShell script
- PowerShell scripts are really powerful and could do much stuff in fewer lines.
- Variables are declared in the form $<variable>
- Variables could be used to hold the output of command, objects, and values.
- “Type” of a variable need not be specified.
Conclusion:
PowerShell is a powerful and robust task automation and configuration management framework from Microsoft that consists of a command-line shell along with scripting language built on the . NET framework.Hope you have found all the details that you were looking for, in this article.