Windows PowerShell Introduction


This entry is part 1 of 9 in the series PowerShell

Windows PowerShell is the command and scripting language from Microsoft built into all versions of Windows since Windows Server 2008.

I have a previous blog post introducing the Windows 10 command line. The Windows 10 Command Prompt can trace its ancestry back more than three decades. Windows PowerShell is distinctly more modern, with version 1.0 arriving on the scene a mere decade ago.

Windows PowerShell helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows. PowerShell is built on top of .NET Framework which gives an edge over the other tools when it comes to integration and automation of Microsoft products and technologies. There is also .NET Core available for Linux and Mac. For a good explanation of some of the history of how DOS evolved into PowerShell have a look at the YouTube video called PowerShell Master Class – PowerShell Fundamentals. In PowerShell type $psversiontable to get the version.

To start the PowerShell console, in Windows, click the Start button, type powers, and then right-click Windows PowerShell and then click Run as administrator.

Add Powershell Icon to Windows Explorer

To set up a PowerShell icon in Windows Explorer, click File > move the mouse over “Open Windows PowerShell” and right-click and then click “Add to Quick Access Toolbar”. Click the screenshot at the left to see the help that is visible when uses hover over the small blue icon after the icon has been added to Windows Explorer. Once this is set up you can use Windows Explorer to navigate to the folder that you want to work in. When you click the icon, PowerShell will open up in the directory you are currently using in Windows Explorer. This makes it much easier than using the commands to navigate to the correct folder in the PowerShell console.

Set the Properties

Set the properties of the console by first right-clicking the title bar of the PowerShell window and select Properties. Under the Options tab at the top Be sure that QuickEdit Mode is checked. This sets up all of the copy and paste stuff. If you copy some text you can paste it in the console simply by right-clicking inside the console window. In the Font tab choose a size that works for you.

Learning Resources

The book called Top 10 Tools, Windows 10 IT Pro Essentials by Ed Bott discusses PowerShell, among many other topics. You can download it free at the Microsoft website. You may need to log in to download it.

Ed Bott writes: “The command line is useful for some file management tasks, with syntax that hasn’t changed much since the days of MS-DOS. Thanks to wildcard characters, you can change the extension on a group of files in a folder, for example, using the command ren *.htm *.html. That job is nearly impossible in File Explorer.”

The website Goal Kicker has some notes for PowerShell that are in a PDF format that can be downloaded for free. These notes are based on the posts in Stack Overflow. Here is the link to PowerShell Notes for Professionals.

There is a YouTube video series that starts with a video called Microsoft PowerShell for Beginners – Video 1 Learn PowerShell. It’s about 5 years old but it has over one million views. Shane Young’s video is 27:56 long. The company is BoldZebras.com.

Cmdlets

Poweshell offers you cmdlets (pronounced “command – lets”) instead of a limited set of commands that DOS has. The power of these are twofold: Combining them into scrips and the fact that you have access to control almost anything in Windows, including the file system, the registry, certificate stores, Microsoft Azure, and Office 365. Cmdlets are available in core modules that are included with every edition of Windows 10.

The first command we should type is Start-Transcript. This creates a log file of your entire session. It will include everything that you type in and everything that is displayed on the screen.

PowerShell has tab-complete. If you type start-transc and then press the Tab key, Powershell will complete the command.

get-help

This is one of the first commands you will want to use. Add a word to the end of Get-Help and you can find cmdlets that include that term. If you know there’s a cmdlet for managing BitLocker but you can’t remember exactly which one you need, try Get-Help Bitlocker to display this list.

Another one to try is get-command.

Verb-Noun or Action/Object

Get-Command is an example of the verb-noun rule.

Ed Bott in the book says: “Although Windows PowerShell cmdlets follow consistent capitalization, you don’t need to worry about case. And if you’re not sure of the exact name of a cmdlet, you can press the Tab key and use IntelliSense to offer suggestions. For example, type get-p and then press Tab to see the first matching cmdlet, Get-Package. Keep pressing Tab to cycle through Get-PackageProvider, Get-PackageSource, Get-Partition, and so on.”

Series NavigationPowerShell Hello World >>