top of page
Writer's pictureUzair Ansari

What the heck is Powershell?

Updated: Nov 5, 2021

What is Powershell?

A command line shell for Windows operating systems designed especially for system administrators for automation purposes. Useful in configuration and management of Windows operating systems and it's services. Windows powershell is built on .NET Framework and .NET Framework common language runtime (CLR). Hence it does not return text and instead returns .NET Framework objects. These objects can then be displayed, stored, processed, or exported in files.

Just like any other shell, Windows Powershell has the ability to access the file system on the machine. In addition to this it can access other providers as well like the certificate store, registry path, environment variables. This helps system administrators to fetch the information for reporting purposes or to make configuration changes across the systems on the network. The way to achieve specific task is by using the powershell commands commonly known as powershell cmdlets.

The below mentioned cmdlet helps you get a list of providers available by default.















Understanding the Cmdlet syntax:

So, we have understood what powershell is. Now we will see how we can use powershell.

To understand this, we first need to know that powershell uses Verb-Noun format to work. This means that the first word will be used to instruct the shell as to what action needs to be taken and the second word will tell the entity on which the action needs to be performed. The example below will depict the explanation.








In the above example, we saw that the command Get-ExecutionPolicy returns the execution policy that have been set on the system. The command won't make any change but will only get the result and display it on the screen. Here the Get (verb)

is instructing the shell to get the result of the execution policy (noun).

Likewise, we can use the Set-ExecutionPolicy command to set the policy. Check the image below.



The command will act as per the verb and will Set (change) the configuration on the mentioned noun. In this case, noun will be execution policy. Since it's a critical change, as the change was related to the execution of the script on the system, it prompted us for the confirmation to proceed. When we entered Y (Yes), it made the configuration change.

P.S - We will learn more about execution policy in detail in some other post. The motive here is to help you understand the fashion in which the cmdlets works in powershell.




What are the versions of powershell?

The default installation of powershell version varies as per the operating system. Below is a list of default powershell version shipped with different windows OS.

Powershell 1.0 - Windows Server 2008, Windows XP

Powershell 2.0 - Windows Server 2008 R2, Windows 7

Powershell 3.0 - Windows Server 2012, Windows 8

Powershell 4.0 - Windows Server 2012 R2, Windows 8.1

Powershell 5.0 - Windows 10

Powershell 5.1 - Windows Server 2016, Windows 10 Anniversary Update

Later versions of powershell have been designed for cross platform portability. These versions known as powershell core versions, alongwith Windows runs on Linux based OS as well Mac OS.

Powershell 6.0, 6.1 and 7 have been introduced for cross platform portability. Version 7 being the latest edition.





Uses of powershell:

Over the years, powershell has evolved a lot and it's use has grown extensively from different technologies to different operating systems. Powershell is being used in large number of services and applications. The extensive use of powershell can be seen in the following areas:

1. Managing Operating system : Installing / uninstalling applications, managing registry, certificates, peripherals, disk drives, services, WMI classes. Almost every aspect of operating system can be managed using powershell.

2. Automation : The main use of powershell is to automate tasks. Be it either on your desktop / Laptop, server or cloud. Powershell has proven to be a robust mechanism for automation.

3. Managing windows features : Powershell can be used to install, uninstall, manage windows based roles and features like Active Directory, SCCM, DNS, DHCP, etc. It also has separate module for each of these features to manage it. Active directory will have it's own module to manage active directory. Likewise SCCM will have it's own module. These modules will contain set of cmdlets that helps in managing those feature.

4. Managing Azure services : Powershell can be used to manage and automate Azure services. It has wide collection of modules and commands that can be used to manage different services of Azure like IAAS, Azure AD, Office 365, etc. Almost everything in Azure can be managed from powershell. The main benefit here is that these Azure services can also be managed from Non Windows devices like Mac or Linux as these modules are part of powershell core and can be installed on Mac and Linux as well.

5. Creating GUI based application : While powershell is not an ideal application development language as the primary use of powershell is infrastructure automation. But still it can be used to create some windows form based application.


Hope this article helps you get a clarity about the powershell language, how easy to use the language is, what all can be done using powershell and why is it necessary to learn powershell especially for windows admins.

Comments


bottom of page