top of page
jroberts079

Should You Learn PowerShell Over Windows Command Prompt? Discover the Benefits and Advantages

Are you trying to decide if you should learn PowerShell over Windows Command Prompt? This question lingers in many admin's head, especially up and coming admins who may not share the same experience as their seniors. So based on this title, you would probably guess that we prefer PowerShell but what is the benefit?


PowerShell offers many benefits over Windows standard command prompt. For example, PowerShell is object oriented while Windows traditional command prompt is not. Why is this important? Instead of filtering out strings, you have objects that carry properties that allows you to manipulate your data output. With simplified logic being part of the language, you can write advance scripts using the built in tools. Let's look at an example.


If you run the ping command, you get the following responses.


Input

ping 8.8.8.8

Output


If you want to run a ping command in PowerShell, you will use the following code.


Input


Test-Connection 8.8.8.8

Output



Even though the outputs look similar, the biggest benefit is tied to the control you get with your output. With the use of Properties, you can now take advantage of filtering out what data you want to view. Before we jump into Proerties, let's review the output that was not exposed by the default view. We can perform this by running a pipe with Select-Object *.


Input


Test-Connection 8.8.8.8 | Select-Object *

Output

When reviewing the above screenshots, you can see there is a lot of information we cna filter out. When you are attempting to make an advance troubleshooting analysis, it's important to only view the data you want to pull. Since each of these properties can be called separate, w can create a customer filter by using the Select-Object cmdlet. We will use this to pull the Address, the Timeout, TimeToLive, and the PSComputerName and ReponseTime.


Input


Test-Connection 8.8.8.8 | Select-Object -Property Address,Timeout,TimeToLive,PSComputerName,ResponseTime

Output


if you want to rearrange your output, you can simply update the code. Here is an example of how we can move the response time to be the second value shown in the output.


Input

Test-Connection 8.8.8.8 | Select-Object -Property Address,ResponseTime,Timeout,TimeToLive,PSComputerName

Output

The benefit here isn't necessarily the extra data that is available but it's tied to how easy the output is to manipulate. For example, if you know the server is up but you want to find out the average response time, you can run the following code.

Input

(Test-Connection 8.8.8.8 | Select-Object -Property ResponseTime).ResponseTime | Measure-Object -Average

Output

You can even take the output of a cmdlet and store it as an xml file. Upon importing the file back into your shell, you also access to all the Properties. You can also store the output as a variable that allows you access to all the data from the cmdlet through out your script. The limitations are tied to how powerful our mind can think.


PowerShell also offers support for many admin platforms such as AWS, Azure, Active Directory, VMware, Exchange and many more. Though every language has a benefit, PowerShell is a strong tool that can take your company to the next level. Even if PowerShell isn't your main choice of tools, as an admin, it can help you complete many tasks and give you the foundation knowledge on how to think more logically in terms of programming.


If you can learn how to manipulate PowerShell's inputs and outputs, the structure of scripts and how to control validation, learning other technologies are easier because you don't need to focus on how to implement via confusing GUIs. You simply learn the cmdlets you need to complete your task, the cmdlets to validate your task and the cmdlets to sustain your task. If you can master Script Freaks Recommended PowerShell Skills, you can expect to provide your company domination via automation.



6 views0 comments

Comments


Post: Blog2_Post
bottom of page