Table of Contents
If you are a Windows user then you must have heard about PowerShell & many of you must be wandering why should you learn PowerShell? And how you can learn PowerShell? In this article, we will try to answer these questions.
So before we start learning why and where let’s first learn what was before Powershell. Before Powershell the only command line shell available for windows users was CMD. In fact for over two decades CMD was the only option for windows users. While Linux users always had powerful bash shell available to them. I am not aware why Microsoft did not care about introducing a powerful command line shell much earlier. No offence to CMD but CMD is old school. It is MS-DOS based command line which never stood any chance against powerful bash shell. But better late than never. Windows user do have powershell now. So let’s first know the difference between CMD and powershell.
What is the difference between CMD and Powershell?
If you have studied Windows server then you must know the difference between CMD and Powershell. But if you are a beginner then you must be wondering why there is both CMD and Powershell on Windows server. What is the difference between them? The differences between CMD and Powershell are many. Let’s know some of the main differences to make things clear.
CMD is the first shell that was introduced by Microsoft in 1981 while powershell development started by the year 2002. For years Microsoft focused more in GUI and less on command-based approach. But slowly it became clear that this GUI does not have much significant in return on investment terms. It consumes most of system resources. CMD has helped system administrators a lot in administrative tasks but if you compare CMD with Linux bash shell then CMD looks very much inferior with limited capability and scope to manage the system. CMD does give us the ability to write batch script but to be honest batch script is not very efficient when it comes to automation.
While powershell is object based interactive shell. It is highly useful and efficient scripting tool. In powershell we can execute sequence of cmdlets as a powershell script. We do not have this ability in CMD. Powershell also provides powershell ISE as scripting editor with inbuilt Intellisense. But CMD has only command line interface. With powershell we can also manage our azure cloud subscriptions. But with CMD we cannot manage azure cloud. Powershell can also be installed and used on linux machines. With powershell we can easily pass the output of one command as input to other commands using pipeline which is something very difficult to achieve with CMD.
There is not a single command in CMD which is not available in powershell apart from its own huge list of libraries. Apart from this powershell is supported by a powerful and active powershell community. So in future we will see lots of new features being added in powershell.
But we cannot expect the same from CMD. There are literally N number of things in powershell which are not available in CMD. CMD is a very basic command line shell introduced with the Windows NT family of operating systems and for years it has been continuing with the same standard set of commands with no significant development. But PowerShell is an interactive command line shell and scripting language built on top of .Net framework which gives it immense ability to accept new powerful changes and development.
Now that we know some basic difference between CMD and powershell let’s understand why should we learn powershell.
Why should we learn PowerShell?
To know why should you learn powershell you must first know why do we need powershell because both are related questions.
Now since you are reading an article on powershell so I am assuming that you must be aware about the importance of automation or at least you must have heard it from your colleague , your boss , your mentors or at least you would have read it somewhere. Now before powershell there was no powerful automation capabilities in windows like that existed for linux users. Many windows admins were just happy clicking through the graphical user interface. Graphical user interface is a great thing as it gives you lots of opportunities to explore. You do not have to read everything in book.
You can just start exploring the GUI and understand several things by yourself. It was a comfort zone for several windows users. But for serious windows administrators it was a painful process as this GUI did not have much significance in return on investment terms.Suppose you have to create 5000 users account or you have to do the same repetitive tasks again and again. Without proper automation shell you have no other option then to click through several GUI windows each and every time manually. It is a waste of time.
If you could just automate those steps then you can either do much more productive work in the time that you save or you can just relax and take a nap. And as business started to grow it became increasingly difficult to manage everything with GUI. Though there was command line and VB script at that time also but it lacked seriousness when it comes to automation.
I remember working with batch script in my earlier days as system admin to automate our tasks. The code used to become too lengthy. I remember writing a batch script and VB script for a group policy for one of the bank. Our task was to make sure that the screen in ATM machine does not lock and it prints passbook after transaction and a couple of other tasks. The script became very lengthy and there were too many errors and obstacles that we have to overcome to prepare that script. It was all because command line based script was not a proper automation tool.
On one side there were linux users with powerful bash shell and on other side there were windows users with command line based batch script. It was like one soldier armed with AK47 on one side competing with another soldier with a knife on the other side.Though there was VBScript also. VBScript was good for automation but it had two major shortcomings. One was that Microsoft never paid attention to its development. Several of windows feature were not supported in VBScript because Microsoft did not develop it. And the other shortcoming was that VBScript was a pure developer tool.
So several windows administrators just did not want to use it. Several times we used to write a combination of VBScript and command line based batch script to achieve our automation task. But it was never good enough until powershell came. Powershell came into the life of windows users and made their life easier. Now all those lengthy script started getting shorter and things that were not possible to automate earlier became easier to automate.
Not only this, powershell proved to be very useful as an interactive shell. In fact powershell at its core is an interactive shell. Powershell is very easy to learn. You can leverage powershell to automate .Net objects, COM objects, WMI, XML or active directory. You can read excel file with powershell and create beautiful HTML reports. In fact we can use powershell for ethical hacking and penetration testing as well. So no wonder why powershell has become so important for windows users. If you are a windows user then you cannot afford to ignore powershell. If you are working in IT industry and you know powershell then rest assured that you are having an edge over others.
How can you learn powershell?
The best way to start learning powershell is to build a network of 2–3 machines using virtual box or vmware workstation and then start playing with powershell. We have a separate post on setting up lab to learn powershell. You can read it here.
Without any external help your friend will be the discoverability feature of powershell. Also called Help pages. Open powershell on your machine and then use Get-Help cmdlet to search and learn for anything in powershell. For example if you want to know what cmdlets are available in powershell related to services then you can use Get-Help *service command. Similarly if you want to see the help pages of any cmdlets then you can type Get-Help Get-Process. And using google search when required is always helpful.
But still it is possible that you may find it frustrating to learn all by yourself in the beginning. Who would not want a little help to make their life easier. You need to follow correct approach to learn powershell quickly and effectively. For this you will need help. Off course you can learn by yourself with just google search but that will take lots of time to learn everything and it will not be in a step by step sequential manner. And I prefer to climb stairs step by step rather than jumping to avoid risk of falling back. Now the help can be in any form.
Either you can join a crash course classroom training, you can get help from a PowerShell expert that you know or you can get help from any good books. I learned PowerShell from books. So I would suggest you follow any good book in Powershell. Books contain knowledge in a sequential manner. The author knows what you need to learn first and what you need to learn next. So it helps you to learn technology effectively in less time. There are several books available both at a small price and also free. I would recommend starting following this book on PowerShell: Complete Powershell Guide — Beginner to advanced level : Learn by examples (1000+ examples).
This book contains a huge number of topics and examples and the explanations are very simple and easy to understand. Even if you have no prior experience with any sort of command line or scripting language, you won’t find it difficult to learn powershell if you follow this book from beginning. And if you are on kindle then you can read this book for free.
You can also browse our blog posts as your source of learning. We will keep on publishing new exciting and knowledgeable posts on PowerShell. An easy way to get update on new posts is to subscribe to our newsletter.
However, if you have any other book or resources available then you can also use those resources to learn Powershell. Microsoft docs is also a good place to learn Powershell but a beginner may find it confusing or complicated at first. And don’t forget to subscribe to TopTechNotes.com. We will keep on posting new articles on PowerShell.