How to start learning PowerShell

How to get started with PowerShell
GagoDesign / Shutterstock

“Yes, I know a little about PowerShell,” perhaps one of the most used statements at technical conferences over the years. Not many statements can be made, which can be both an understatement and an exaggeration.

Some who say this are quite modest, although they probably know a lot about PowerShell. Others tend to think knowing concerning PowerShell qualifies knowing how to use it. For those who don’t know how to use it, which is still a big part of the crowd for systems maintenance and engineering, it can be quite a daunting thought to think about where to even start using PowerShell. You have heard countless technical speeches, read pages of articles and had many conversations with colleagues about everything he can do for you. You are looking up at this rising mountain and all you can do is focus on the top and it obviously escapes you when it comes to planning how to get to this top. This first step is right in front of you, at the bottom of the mountain. Let’s take this first step together.

You may not know anything about PowerShell and that’s OK

Let’s get this out of the way. If you don’t know PowerShell, that’s fine. All is well if you know about PowerShell, but it’s good to clear up if you’ve never used it. Nodding in agreement with peers and throwing PowerShell in your resume to hopefully gain an advantage can become a reality much sooner than you think. Everyone has their own PowerShell story and yours will be as unique as your journey through the world of IT support and engineering. You have nowhere to go but up!

According to Microsoft Docs, PowerShell is a cross-platform task automation solution consisting of a command line shell, scripting language, and configuration management framework. PowerShell runs on Windows, Linux and macOS. The focus of this publication will be strictly on the Shell part of PowerShell and the main focus on this. Other aspects combine with a little more clarity as you gain more experience with the PowerShell shell.

Microsoft has developed PowerShell and is continuously developing PowerShell for interoperability with Windows desktop operating systems, Windows Server operating systems, Office 365 resources, and Azure cloud resources. It will be an integral part of almost the entire universe of Microsoft products. PowerShell allows engineers and support staff to manage their responsibilities more efficiently by allowing batch creation and modification of resources such as files, folders, settings, and configurations. It is best known for its unique and easy-to-use nomenclature of verb-noun commands, pronounced ‘command-lets’. Command commands are the actual commands used to do something with PowerShell. Some cmdlets can be executed exactly as they are, without defining parameters. Enter them, press enter and BOOM! You have an output given to you in the console. If you are familiar with the always correct command line in the middle of Windows, you will feel very comfortable with PowerShell. Many of the commands that you typically run on the command line can also be executed in a PowerShell console. If nothing else, try the next time you normally use the command line. See how it can do the same things in the PowerShell console.

Detach the GUI veil

Most people love their valuable GUI. They can see everything they think they need to see, and they get that warm and blurry feeling when they click Apply and then OK. Some of them like to live on the edge and completely miss the push of Apply! Eventually, as you delve deeper into managing servers, desktops, or Exchange, you’ll find yourself clicking endlessly when a change needs to be made that requires adding 360 users to 20 different Active Directory security groups. Are you squeezing your fingers for this clicking nightmare?

It is safe to say that PowerShell helps to unveil the veil, which is a valuable and beloved GUI. PowerShell allows you to take on this task of placing AD users in multiple groups and designing multiple commands to do the job in just a fraction of the time it would take to do everything through the GUI. The good thing is that Microsoft want to use PowerShell for these tasks. With the emphasis on using PowerShell in many of Microsoft’s core certification exams, it’s no longer just for experienced administrators, but it’s becoming something you need more often in your daily maintenance toolbox. It is relatively accurate to say that any action, button, setting, or configuration you see in the GUI can be manipulated and configured using PowerShell, even down to the essence of the registry.

Taking the first steps

Let’s start with a few cmdlets that you can use right now if you’re reading this on a Windows computer. One thing that most system administrators and engineers interact with is the service console. If you open the PowerShell console, just type Get-Service and press Enter to get a list of installed services. You will received quick blast of everything services installed in the local system and their current state of Running or Stop. This output would be convenient to see if a particular application service works or not.

PowerShell Get-Service and Exit

Maybe you don’t want the whole list of services, but are looking for a specific service. Let’s say you want to see if the spooler service works. You can call it by name using the -ServiceName parameter as follows:

Get-Service -ServiceName spooler

PowerShell Get-Service for spooler service status

This output will give you a single list of the Print Spooler service and its status. Assume that the service is currently started or stopped and you want to either stop it or start it. You can use the following input to stop / start the spooler service:

Start-Service -ServiceName spooler
Stop-Service -ServiceName spooler

PowerShell manages Stop-Service and Start-Service services

By default, these lines will not list the status of the service when the command is sent. You will have to run Get-Service -ServiceName spooler to see the current status.

Fortunately, PowerShell is very handy for wildcards when listing objects and names. Let’s say you need to check a specific service, but you’re not quite sure how the service is an “official” name. All you know is that the first word is distant. This is easy:

Get-Service -ServiceName remote*

PowerShell Get-Service remote wildcard

This entry will list all services starting with remotely and allow you to narrow your search to find the specific service you are looking for and do what you need to do. Remember that there is also a Restart-Service cmdlet.

Taking this just one step further, to get a return on this little knowledge of services, let’s check out the services on a remote computer. Suppose you are in a Windows domain environment and have administrative access to the remote computers that you manage. You can use the same cmdlets discussed earlier, but you must add one parameter and value. To check the spooler service for printing to a remote server named PrintServer01:

Get-Service -ComputerName PrintServer01

This output will list all the services installed on the remote machine, just like the local system we did earlier. This cmdlet will save you from using RDP to log in to the remote server to check the service, or to add the remote server to a local MMC add-on. This ability in itself pays off very quickly.

Another command that can be used directly from the box without parameters is Get-NetIPAddress. This cmdlet will give you a list of all network adapters in the local system and a good amount of information about each adapter. In this output you see the internal work behind the GUI. You can see a lot more information about things that you usually see as an icon in the GUI. The beauty of seeing more information is that you can always use PowerShell to manipulate and search for any of this additional information. For example, if you want to make changes to specific network adapters, you can search or filter only those with a certain value. The possibilities are endless!

Where to learn more

Now that you have the thinnest bits of PowerShell experience, it’s up to you to continue your search up this mountain discussed earlier. Putting one foot in front of the other is as easy as browsing some PowerShell tips resources. A simple Google search in the cmdlet is a good start. Microsoft Docs has a powerful library for each cmdlet with many examples of how to use them. PowerShell itself provides a good resource for explanations and examples. The team Get-Help Get-Service will give you more information about our example above.

PowerShell output for Get-Help Get-Service

One resource that many experienced PowerShell users will remember is the book with the highest rating by Don Jones and Jeffrey Hicks. These PowerShell giants have the shoulders that many stand on when it comes to conquering the mountain of PowerShell. The book is entitled “Learn Windows PowerShell in a month’s lunch.” This easy-to-read book takes you through the basics of getting to know PowerShell in small pieces, and will ultimately be a resource you will constantly refer to when you find yourself in a situation where you need to use PowerShell.

The PowerShell community is also a very open and useful place to learn. Subreddit r / PowerShell and the site have a very thriving community of people with varying degrees of experience. You can always get some guidance from these resources. You won’t be able to climb this mountain unless you take the steps, so go ahead and see how PowerShell can help you with your daily routine and daily tasks that you sometimes dread. You may find it frantic to plan and automate much of your workload so you can take the time to learn more about PowerShell!

Related Posts

Leave a Reply

Your email address will not be published.