“Yeah, I know a little about PowerShell,” may be one of the most widely used statements at technical conferences over the years. You can’t make many statements that can be as underestimated as overrated.
Some who say that are quite modest, although they probably know quite a bit about PowerShell. Others tend to think they know O PowerShell qualifies as knowledge of how to use it. For those who don’t know how to use it, which is still a big part of the system support and engineering crowd, it can be quite daunting to think about where to start using PowerShell. You’ve heard countless technical speeches, read the pages of articles, and had a lot of conversations with colleagues about what they can do for you. You look up this rising mountain and all you can do is focus on the summit, and what is obvious is eluding you when it comes to planning how to get to the summit. The first step is right in front of you, at the foot of the mountain. Let’s take the first step together.
You may know nothing about PowerShell, and that’s fine
Let’s get it out of the way. If you don’t know PowerShell, that’s fine. Everything’s fine if you know PowerShell, but if you’ve never used it, it’s fine to clean it. Agreeing in fellowship discussions and throwing PowerShell at your resume to hopefully gain an advantage can become a reality much faster 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 that consists of a command-line environment, a scripting language, and a configuration management framework. PowerShell runs on Windows, Linux, and macOS. ”This post will focus exclusively on the Shell portion of PowerShell and its core focus. As you gain more experience in the PowerShell shell, the other aspects come together with a little more clarity.
Microsoft has developed PowerShell and is constantly developing PowerShell to interact with Windows desktop operating systems, Windows Server operating systems, Office 365 resources, and Azure cloud resources. It will be an integral part of almost all Microsoft products. PowerShell enables engineers and support personnel to more effectively manage their responsibilities by enabling bulk creation and modification of resources such as files, folders, settings, and configurations. It is best known for its unique and user-friendly nomenclature of verbs and routine nouns, pronounced as ‘command-lets’. Routines are actual commands used to do something with PowerShell. Some routines can be run exactly as they are without defining parameters. You enter them, press enter and BUM! You have received output in the console. If you still know the faithful command line in the Windows environment, you will feel very comfortable with PowerShell. Many of the commands you would normally run from the command line can also be run in the PowerShell console. If anything, try it the next time you usually use the command line. See how he can do the same things inside the PowerShell console.
Graphical user interface haze peeling
Most people love their rare GUI. They can see everything they think they need to see, and when you press Apply and then OK, they get that warm and blurry feeling. Some of them like to live on the edge and completely skip pressing the Apply button! Eventually, as you get deeper and deeper into server, desktop, or Exchange management, you’ll find that you’ll keep clicking when you need to make a change that requires adding 360 users to 20 different Active Directory security groups. Do you have your fingers up for that tortuous nightmare?
It is safe to say that PowerShell helps peel off the veil, which is a rare and popular GUI. PowerShell allows you to take on the task of dividing AD users into multiple groups and designing several commands that will do the job in just a fraction of the time it would take through the GUI. The beautiful thing is that Microsoft he wants you can use PowerShell for these tasks. With an emphasis on using PowerShell in many of Microsoft’s major certification exams, this is no longer just for experienced administrators, but is becoming more and more common in the day-to-day support toolkit. It is reasonably accurate to say that any action, button, setting, or configuration you see in the GUI can be manipulated and set up using PowerShell, even in the smallest details of the registry.
Business first steps
Let’s start with a few routines that you can use right now if you are reading them on a Windows computer. One thing most system administrators and engineers work with is the Services console. If you open the PowerShell console, just enter
Get-Service and press enter to see a list of installed services. You will get quick blast of all services installed on the local system and their current status is Running or Stopped. This output would be useful for determining whether a particular application service is running or not.
You may not want a complete list of services and are looking for a specific service. Let’s say you want to see if the spooler service is running. You can call this by name using the -ServiceName parameter as follows:
Get-Service -ServiceName spooler
This output gives you a single listing for the Print Spooler service and its status. Let’s say the service is currently running or stopped and you want to stop or start it. You can use the following input to stop / start the spooler service:
Start-Service -ServiceName spooler Stop-Service -ServiceName spooler
By default, these lines do not indicate the status of the service when the command is sent. You will have to run
Get-Service -ServiceName spooler to display the current status.
Fortunately, PowerShell is very friendly to wildcards when listing objects and names. Let’s say you need to check a specific service, but you’re not entirely sure what the service’s “official” name is. All you know is that the first word is distant. It is simple:
Get-Service -ServiceName remote*
This entry displays a list of all services starting with remote and allow you to narrow your search to find the specific service you are looking for and take whatever action you need. Remember that there is also a Restart-Service routine.
If we take it a step further to get a return on this tiny knowledge of services, let’s check the services on the remote computer. Assume that you are in a Windows domain environment and have administrative access to the remote computers that you manage. You can use the same routines described above, but you must add one parameter and value. To check the print spooler service on a remote server named PrintServer01:
Get-Service -ComputerName PrintServer01
This output displays a list of all the services installed on the remote computer, as well as the local system we did earlier. This routine saves you from using RDP to log on to a remote server to check the service or add the remote server to the local MMC snap-in. This ability pays off very quickly on its own.
Another command that can be used immediately after unpacking without parameters is Get-NetIPAddress. This routine provides you with a list of all network adapters on the local system and a large amount of information about each adapter. In this output you see the internal operation 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 displaying more information is that you can use PowerShell at any time to manipulate and search for any additional information. For example, if you want to make changes to specific network adapters, you can search for or filter only those with a specific value. The possibilities are endless!
Where to find out more
Now that you have the thinnest bit of experience with PowerShell, it’s up to you to continue the search for the mountain we talked about earlier. Putting one foot in front of the other is as easy as browsing through some PowerShell resources. A good start is a simple Google search in the routine. Microsoft Docs has a powerful library for each individual routine with lots of examples of their use. PowerShell itself provides a good resource for explanations and examples. Command
Get-Help Get-Service will give you more information about our example above.
One of the resources many experienced PowerShell users remember is the best-rated book by Don Jones and Jeffrey Hicks. These PowerShell giants have the shoulders that many stand when it comes to conquering PowerShell Mountain. The book is called “Learn Windows PowerShell for Lunch Months.” This easy-to-read book walks you through the basics of learning about PowerShell, and will eventually become a resource that you will keep coming back to when you need to use PowerShell.
The PowerShell community is also a very open and useful place to learn. Subreddit r / PowerShell and PowerShell.org have a very thriving community of people with varying degrees of experience. You can always get some advice from these sources. You won’t be able to conquer this mountain until you take the steps, so go ahead and see how PowerShell can help you with your daily routine and the everyday tasks you sometimes dread. You may find yourself frantically planning and automating a significant amount of your workload so that you can take the time to learn more about PowerShell!