Windows PowerShell – You mean I have to learn how to type!
Unless you’ve been out of the office or stuck in the bowels of you data center for the past year, you should know that Windows PowerShell is here and it’s here to stay. But you may ask: What is Powershell and how do I use it? I like to point and click, why do I have to type? I’ll start by telling you that PowerShell is an extensible automation engine. It consists of a command line shell with an associated Microsoft scripting language.
Did you say? Command line, shell, and scripting!!! But I like to point and click and I like to use the wizards. Yes I know we all love to point and click and maybe you can’t type 60 words a minute, but wizards are going to disappear, my friend. Plus the major problem with wizards is that they make engineers think they can configure things properly, regardless of whether or not they know what they are doing. An engineer must always know what he or she is doing and not follow someone else’s script. Like it or not, PowerShell is Microsoft’s new management tool and you’re going to have to learn to use it.
So let’s cover a few of the basics.
First we need to have PowerShell installed on your computer. The current version is now at 2.0 If you don’t already have PowerShell installed you can download it from the following Microsoft site: https://connect.microsoft.com/windowsmanagement/Downloads. Once it’s installed and ready to go you’ll notice it looks a lot like a command prompt window, except it says Windows PowerShell at the top and it starts your command prompt path with a PS. The first thing, with all new command line interface software is to get to know the help menu (this could be your best friend).
At the prompt type: Help *
Use the space bar to pass through the topics. Pick one topic and look at the full help menu: Help Get-Process -full. You will get the full syntax, parameter description and full working examples. Every command in PowerShell is documented. Run this: Help about_wildcard. This will display the topic information for the Wildcard construct.
PowerShell is an object based shell, unlike the text based shell of cmd.exe. Even though you are typing commands and seeing text, you are accessing objects. Sort of like an object oriented programming language such as Java. Whoa! Programming! Ok let’s try some more commands. Type: Get-Process. This calls the Get-Process cmdlet, which shows you all of the running process on the system. Then type: Get-Process | Get-Member. This takes the result of Get-Process and sends it to the Get-Member cmdlet. The Get-Member cmdlet tells you everything about an object, in this case it’s a running process object with a variety of properties. Let try some more commands shall we. Type: Get-Psdrive. This will show you all the drives on your computer along with your current location. Type the following command: cd hkcu:\printers then type in dir. You are now looking at the registry on your computer, specifically the current user’s printers. Now type cd c:. You are now back to the C: drive.
Let’s try some pipelined expressions. PowerShell cmdlets are designed for single purposed tasks, but by sending objects from once cmdlet to the next we can achieve some cool results. So we’ve already tried the Get-Process cmdlet. Type this: Get-Process | sort workingset -descending | select -first 5. We just sorted the list of the top 5 processes based on the workingset size.
So if I haven’t bored you to tears or worse yet put you to sleep, let’s look at the full help menu for the following cmdlets: Where-Object, Select-Object, Out-File,Out-Printer, and Get-WMIObjects. Windows PowerShell is the management tool of the future so continue to explore or pick up a helpful PowerShell reference book and happy administrating.
For additional information about Windows Powershell contact your network support team today.