What is PowerShell?
What exactly is PowerShell? A scripting language? A command line interface? Well both and more, PowerShell is a platform that provides the ability to interface with your environment via a number of tools, called cmdlets. PowerShell can be used to perform a number of tasks such as gathering remote computer information, performing user tasks and troubleshooting system problems, so whether you’re an entry level helpdesk technician or experienced IT Professional, PowerShell is a tool you’ll need to learn.
Why we need to know PowerShell?
Well, it’s not going anywhere, Microsoft products all support PowerShell as a basis for administration, from Windows Server to Exchange, and back to SQL, all have a library of Cmdlets available to the IT Professional. It can be used to manage a number of 3rd party products such as VMware VSphere, and this support from 3rd parties will only increase over the coming months / years.
Thirdly, if you are planning to take any Microsoft certifications you better get familiar with PowerShell. I can tell you from experience that all three exams on the MCSA: Windows Server 2012 track, contain a significant number of questions on PowerShell. In short, Microsoft is all in on PowerShell.
Demo
In this first demo, I’m going to generate a list of services running on my laptop, and gradually by using cmdlet together the output will be reduced down to produce a clear list of data which can then be exported to a csv file, which theoretically could be a report you email to your boss.
PowerShell commands (cmdlets) and be executed via the command line interface often referred to as the CLI, or via the PowerShell ISE or integrated scripting environment. In this first demo I’m going to use the CLI. To launch the CLI, type PowerShell in the search and select the PowerShell desktop app, see below
This will launch Windows PowerShell CLI, as shown below. From here you can run numerous PowerShell commands and see the results, the first one I’m going to experiment with is the get-service cmdlet.
The cmdlet, get-service will return a list of all the services running on my laptop. As you can see it just generates a list of services, their running stats “stopped or started,” Name and DisplayName.
However, say you need to see only the services which are stopped, well you can use the “where-object” cmdlet, in conjunction with “get-service.”
get-service | where-object status -eq ‘stopped’
Using a couple of additional cmdlets, such as select-object and export-csv its possible to product a reports that could be sent to field engineers, your IT manager, or documentation. Examples below
get-service | where-object status -eq ‘stopped’ | export-csv c:\temp\export.csv
get-service | where-object status -eq ‘stopped’ | select-object status, Name, displayname |export-csv c:\temp\export2.csv
So there it is, a brief introduction to PowerShell, if you run a get-command you should see a list of all the cmdlets and functions available to the IT Professional, in the next post I’ll continue to work with the CLI, looking at the get-help cmdlet, get-history and further PowerShell basics.
Thanks for reading
TSP Admin