Powershell Computing

Anthony E. Alvarez
Tech Jobs Academy
Published in
5 min readFeb 25, 2016
Whenever you reach for command prompt, stop yourself and use PowerShell instead. Try it, you’ll like it.

This is a getting started guide to PowerShell, how to start using it, and what features you can readily use in your daily IT work.

PowerShell is a command line interface (CLI) tool used to control a Windows PC. It is designed to help system administrators automate repetitive tasks they regularly perform.

How to Setup PowerShell

The latest version of the product is 4.0. It is a free download from Microsoft. It works on Windows 7 and above.

Start using PowerShell now

To get started quickly, just forget about using the normal Windows command prompt (C:\>) and start using PowerShell prompt instead (PS C:\>). PowerShell provides everything command shell gave you plus easy-to-use commands that will help you automate tasks and work more efficiently.

Use Get-Credentials to authenticate scripts. Its more elegant than putting passwords into scripts

Using PowerShell

For Windows 8 and above users: push Windows Key to get to desktop. Start typing the word “PowerShell” which will automatically open start menu to launch the program. For Windows 7 users, go to the start button and in the search input area, type “PowerShell” to find the PowerShell icon in the start menu.

This is your start button.

Alias commands

In order to speed up adoption, PowerShell includes aliases for those already familiar with MS-DOS, UNIX, and Windows native commands. Aliases in PowerShell are shortcuts to real PowerShell Cmdlets; pronounced as “Command-lets” and rhymes with (Java) Applets.

Unix aliases in PowerShell

Below are popular UNIX commands that are already implemented PowerShell as aliases.

PS C:\> ps 
PS C:\> ls
PS C:\> chdir
PS C:\> cp
PS C:\> kill
PS C:\> grep
PS C:\> mv
PS C:\> mkdir
PS C:\> man
PS C:\> cls

Windows Native Commands aliases in PowerShell

Below are major Windows Native command shell programs that also work in PowerShell.

PS C:\> notepad
PS C:\> calc
PS C:\> explorer
PS C:\> ipconfig
PS C:\> nslookup
PS C:\> ping
PS C:\> cls
PS C:\> cd
PS C:\> ren
PS C:\> rm
PS C:\> dir
PS C:\> tasklist
PS C:\> taskkill
PS C:\> mspaint

Get-Alias provides a list of current PowerShell Aliases. In fact, Get-Alias g* command provides a list of current PowerShell Aliases that start with the letter “g.” In addition, “gal” is a alias for “Get-Alias.”

PS C:\> Get-Alias
PS C:\> Get-Alias g*
PS C:\> gal *sv
PS C:\> gal st*
PS C:\> gal spsv

As in all CLI environments, the asterisk (*) means everything and is one of the most commonly used symbols used in regular expressions.

Automate repetitive task using Cmdlets

Love Unix or hate it, PowerShell borrows many ideas from Unix, especially the composition model of scripting. That is, PowerShell scripts should be very small and the script author should leverage the PowerShell “engine” and avoid writing full-blown programs. In order to create complex routines, the pipe character (“|”) is used extensively, as in Unix, to perform larger tasks by chaining commands together and thus creating complicated functions. In this programming model, the output from the first command becomes the input of the next command and so on.

Compared to Windows, Unix is a document oriented operating system (OS), because a lot of the routine management and administration is done by editing text files. Windows simply cannot be managed in the same manner as Unix, the management style is completely different. Unix tools like bash, grep, awk, and sed are used for text manipulation in Windows, while in Unix they are used as management tools for the OS.

On Unix, most config information comes from text files, and text files are ridiculously easy to edit. By contrast, Windows is built around an enormous set of disparate Application Programming Interfaces (APIs). To get CLI commands to work on Windows is not only harder, but it’s essentially a never-ending task. And prior to PowerShell, you basically had to use a Graphical User Interface (GUI) to manage Window objects like the registry, WMI, or Active Directory. Because Windows is an API oriented OS, traditional Unix configuration management tools just do not work well on Windows.

Example PowerShell Commands

Get-WindowsFeature
Install-WindowsFeature
Enable-ADAccount
Test-NetConnection
New-NetRoute
Restart-Service
Stop-Service
Start-Service

PowerShell follows a simple model of composition using familiar verb-noun grammar and a well defined set of parameters.

This allows for regularity that allows a systems administrators to automate repetitive and error-prone operations. It’s an extensible schema that most people can pickup quickly. Due to PowerShell’s similarity with natural language grammar, even non-programmers can get the gist of Powershell.

PS C:\> help
PS C:\> man
PS C:\> Get-Help

For help, Powershell.org is a community-based website intended to be a central starting point for entry into this field. The website coordinates a number of services and events that help foster community engagement, and provide a platform for members of the community who want to contribute to the common base of knowledge and expertise with PowerShell.

To log bug reports and/or submit suggestions for PowerShell, use the Microsoft Connect website.

Summary

In my opinion, PowerShell and the push for “Desired State configuration (DSC)” is part of a larger ecosystem called “IT server automation software.” It shares this marketplace with offerings from Puppet, Chef, and Docker. In a world of virtualized servers, disks and storage spaces, PowerShell is a key piece in Microsoft’s Windows Management Framework.

Getting started using PowerShell is simple. Whenever you open Windows command prompt, stop yourself, take a deep breath and use PowerShell (PS C:\>) instead because it offers all the features of command prompt and much more. It’s the future.

--

--

Anthony E. Alvarez
Tech Jobs Academy

Digital Marketing Services. Tell your own story the way you want too. Helps business owners use websites for branding, sales, marketing, and customer support.