When I talk about what I do at my job, people will generally have heard of ‘Javascript’ or ‘Python’, but ‘PowerShell’ seems to be a bit more obscure.
When asked, “What’s ‘PowerShell’?”
I will generally respond, “Oh, it’s kind of like… an ‘in-built’ programming language for Windows.”
And that usually ends the conversation; because the type of person who has never even heard of PowerShell- probably doesn’t want to sit and endure me talking about “Programming languages for Windows”- life is too short. And I can respect that.
So this post is “the stuff I would say, if ever pressed in a casual conversation about what PowerShell is”
A mixture of things I wish someone had of explained to me when I was first starting out; and stuff I generally find interesting as ‘trivia’ (I hope the non-IT people reading this will find some things interesting too).
If not, no worries. But if you are; you can open a PowerShell window now and see it for yourself in all its glory. Go ahead and hit the Windows key, then type ‘powershell’. Open it up. It’s probably blue (there are different versions- you might have a black background).
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Yeah cool. It might look familiar. You’ve probably seen command-line interfaces like this before; if not in-person, then on a TV-show or movie. When I was a kid, the first time I messed around in a terminal window- it felt like I was doing “real computery-stuff”. I think this causes many people to shy away from command-line interfaces- its the same feeling as when you open the breaker-box to reset your home’s electricity; “This stuff seems important, I barely know how it works, and I shouldn’t be touching it” close box.
Maybe you’ve had to set-up your home wifi network and you’ve typed ipconfig
or ping
in a command-prompt before. Those same commands will work in your PowerShell window, you can go ahead and type ping http://www.barclaymcclay.au
for a demo if you want. But what actually are these things? How do people use them? Why do people use them like this?
In the late 1950s and 1960s, computers were huge appliances that dominated the space of an entire room.
These giant computers would have ‘endpoints’ or ‘terminals’ where a human could stand or sit at a screen and read information displayed by the computer. These were called terminals because it’s where the information would ‘end-up’. It’s the computer’s output, or its, ‘terminus’- so to speak.
Putting information into a computer usually involved configuring some form of physical media (maybe punch cards, paper-tape, or a series of switches/buttons/knobs) with a list of tasks or ‘commands’. This list of instructions was called the computer’s ‘program’. The program would then be fed into the computer, and the computer would carry out all the commands on it as instructed.
When computer keyboards became a thing in the 1970s, technicians could now input their commands for the computer directly into these terminals. So no more need to craft punch cards; no more need to flip switches and push buttons in a particular order to get your computer to do what you wanted. You’d just type, “do this thing” and it’d do that thing. Then you could type “do this other thing” and it would do that other thing also. We take this for granted now; because keyboards have held their place as the main way humans input information into a computer ever since their invention. Much (if not everything) has changed about computers in the last 50 years; but the humble keyboard endures.
The 1980s saw the ‘graphical user interface’ (or ‘GUI’) come to the party. Most people today only interact with computers through GUIs. I can say with 99.9% certainty that (unless you printed this page out for some reason) you are viewing this webpage as displayed by your computer’s (or phone/tablet/whatever device’s) GUI. When you pair your phone to your Bluetooth speaker, you don’t have to feed your speaker a punch card; you don’t need to type a command into your phone using some kind of programming language. Instead, you tap a few icons and navigate through a few graphical menus- pushing virtual ‘buttons’ that are visually represented as such on the screen. All that is the ‘GUI’. Revolutionary stuff.
Well, PowerShell is (in-part) a sort of “emulation” of this old-school pre-GUI method of interacting with the computer. When we open up PowerShell on our modern computers, we say we are opening a ‘terminal window’. If you’re on a MacOS or Linux-flavoured device, you can open up a terminal window if you search for ‘Terminal’. Notice how the terminology used in the 60s and 70s (programs, terminals, commands) are still in-use today; they just have a more ‘modern’ technological context now.
All GUIs are a layer of abstraction placed on the computer to simplify its use. If we remove that layer of abstraction, and type commands into the computer directly- we can perform tasks that would be tedious to do in a GUI. For example, if you’re reading this on a laptop right now- and I asked you to make a new folder on the desktop and name it ‘junk’. No worries, right? But what If I asked you to make one-hundred sub-folders within ‘junk’, all labelled 1-100. You’d be groaning (or you should be groaning) if you were expected to make 100 individually named folders using the GUI.
Right-click > New Folder > “001”, Right-click > New Folder > “002”… all the way to “100”
Sounds like like a hellish way to spend the next 15 minutes.
Using a command-line interface instead of a GUI lets you type out exactly what you want to do, then leaves it to the computer do all the tedious legwork:
0..100 | % { $folderName = Join-Path (Get-Location) $_; mkdir $folderName }
This line of code, typed into a PowerShell terminal, would instruct the computer to instantly create 100 sub-folders, all named perfectly.
Yes it is! The ‘language’ you type into a PowerShell window- the code I wrote above- that is ‘PowerShell language’. The extra ‘pazazz’ to it is that its also a shell. Microsoft used to have different command-prompt shells (first ‘DOS-prompt’, later ‘Windows Command Prompt’); You may have ran Windows Key + R > cmd and opened a Command Prompt window before; but if you’re old enough to remember using a DOS-prompt, then odds are you know what all this is about already. Microsoft’s PowerShell offering is relatively newer to the space- first being introduced in the early 2000s.
We wrap our operating systems in ‘shells’. They are called that because they are the ‘outer-layer’ of the operating system. Like a literal shell protects an egg.
Remember, digital computers are built upon an intricately woven mesh of different electronic components. These electronic components operate on binary logic- 1s and 0s. When we as humans use a computer- we’re not ‘manually’ reading each byte in binary form. Programmers don’t sit at computers and write “01101100”. Instead, we have many, many layers of abstraction placed on-top of this binary logic to make it human-useable to its fullest potential. The ‘shell’ could be thought of as the ‘encasing’ for all these layers.
If you’re curious, the other major-player in the shell game is ‘bash’ (short for ‘Bourne-again Shell’). Bash has been around since the 1980s and still is used today in Unix-based systems like Mac and Linux.
Because shells are an interface, not just a ‘language’ of code. You can write complex programs in other languages like C++ or Python, then use your computer’s shell to call and execute those programs. So to take my “creating 100 folders” example from earlier- you could write a PowerShell script that executes 100 programs in a certain order, or at a certain time, or under specific conditions.
At a glance:
Still here? My goodness. Well. That’s the stuff I would say, if ever asked by a particularly persistent and curious person about PowerShell.
…if you really want to delve into it, I’ll go deeper here.
When I talk about what I do at my job, people will generally have heard of ‘Javascript’ or ‘Python’, but ‘PowerShell’ seems to be a bit more obscure.
When asked, “What’s ‘PowerShell’?”
I will generally respond, “Oh, it’s kind of like… an ‘in-built’ programming language for Windows.”
And that usually ends the conversation; because the type of person who has never even heard of PowerShell- probably doesn’t want to sit and endure me talking about “Programming languages for Windows”- life is too short. And I can respect that.
So this post is “the stuff I would say, if ever pressed in a casual conversation about what PowerShell is”
A mixture of things I wish someone had of explained to me when I was first starting out; and stuff I generally find interesting as ‘trivia’ (I hope the non-IT people reading this will find some things interesting too).
If not, no worries. But if you are; you can open a PowerShell window now and see it for yourself in all its glory. Go ahead and hit the Windows key, then type ‘powershell’. Open it up. It’s probably blue (there are different versions- you might have a black background).
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Yeah cool. It might look familiar. You’ve probably seen command-line interfaces like this before; if not in-person, then on a TV-show or movie. When I was a kid, the first time I messed around in a terminal window- it felt like I was doing “real computery-stuff”. I think this causes many people to shy away from command-line interfaces- its the same feeling as when you open the breaker-box to reset your home’s electricity; “This stuff seems important, I barely know how it works, and I shouldn’t be touching it” close box.
Maybe you’ve had to set-up your home wifi network and you’ve typed ipconfig
or ping
in a command-prompt before. Those same commands will work in your PowerShell window, you can go ahead and type ping http://www.barclaymcclay.au
for a demo if you want. But what actually are these things? How do people use them? Why do people use them like this?
In the late 1950s and 1960s, computers were huge appliances that dominated the space of an entire room.
These giant computers would have ‘endpoints’ or ‘terminals’ where a human could stand or sit at a screen and read information displayed by the computer. These were called terminals because it’s where the information would ‘end-up’. It’s the computer’s output, or its, ‘terminus’- so to speak.
Putting information into a computer usually involved configuring some form of physical media (maybe punch cards, paper-tape, or a series of switches/buttons/knobs) with a list of tasks or ‘commands’. This list of instructions was called the computer’s ‘program’. The program would then be fed into the computer, and the computer would carry out all the commands on it as instructed.
When computer keyboards became a thing in the 1970s, technicians could now input their commands for the computer directly into these terminals. So no more need to craft punch cards; no more need to flip switches and push buttons in a particular order to get your computer to do what you wanted. You’d just type, “do this thing” and it’d do that thing. Then you could type “do this other thing” and it would do that other thing also. We take this for granted now; because keyboards have held their place as the main way humans input information into a computer ever since their invention. Much (if not everything) has changed about computers in the last 50 years; but the humble keyboard endures.
The 1980s saw the ‘graphical user interface’ (or ‘GUI’) come to the party. Most people today only interact with computers through GUIs. I can say with 99.9% certainty that (unless you printed this page out for some reason) you are viewing this webpage as displayed by your computer’s (or phone/tablet/whatever device’s) GUI. When you pair your phone to your Bluetooth speaker, you don’t have to feed your speaker a punch card; you don’t need to type a command into your phone using some kind of programming language. Instead, you tap a few icons and navigate through a few graphical menus- pushing virtual ‘buttons’ that are visually represented as such on the screen. All that is the ‘GUI’. Revolutionary stuff.
Well, PowerShell is (in-part) a sort of “emulation” of this old-school pre-GUI method of interacting with the computer. When we open up PowerShell on our modern computers, we say we are opening a ‘terminal window’. If you’re on a MacOS or Linux-flavoured device, you can open up a terminal window if you search for ‘Terminal’. Notice how the terminology used in the 60s and 70s (programs, terminals, commands) are still in-use today; they just have a more ‘modern’ technological context now.
All GUIs are a layer of abstraction placed on the computer to simplify its use. If we remove that layer of abstraction, and type commands into the computer directly- we can perform tasks that would be tedious to do in a GUI. For example, if you’re reading this on a laptop right now- and I asked you to make a new folder on the desktop and name it ‘junk’. No worries, right? But what If I asked you to make one-hundred sub-folders within ‘junk’, all labelled 1-100. You’d be groaning (or you should be groaning) if you were expected to make 100 individually named folders using the GUI.
Right-click > New Folder > “001”, Right-click > New Folder > “002”… all the way to “100”
Sounds like like a hellish way to spend the next 15 minutes.
Using a command-line interface instead of a GUI lets you type out exactly what you want to do, then leaves it to the computer do all the tedious legwork:
0..100 | % { $folderName = Join-Path (Get-Location) $_; mkdir $folderName }
This line of code, typed into a PowerShell terminal, would instruct the computer to instantly create 100 sub-folders, all named perfectly.
Yes it is! The ‘language’ you type into a PowerShell window- the code I wrote above- that is ‘PowerShell language’. The extra ‘pazazz’ to it is that its also a shell. Microsoft used to have different command-prompt shells (first ‘DOS-prompt’, later ‘Windows Command Prompt’); You may have ran Windows Key + R > cmd and opened a Command Prompt window before; but if you’re old enough to remember using a DOS-prompt, then odds are you know what all this is about already. Microsoft’s PowerShell offering is relatively newer to the space- first being introduced in the early 2000s.
We wrap our operating systems in ‘shells’. They are called that because they are the ‘outer-layer’ of the operating system. Like a literal shell protects an egg.
Remember, digital computers are built upon an intricately woven mesh of different electronic components. These electronic components operate on binary logic- 1s and 0s. When we as humans use a computer- we’re not ‘manually’ reading each byte in binary form. Programmers don’t sit at computers and write “01101100”. Instead, we have many, many layers of abstraction placed on-top of this binary logic to make it human-useable to its fullest potential. The ‘shell’ could be thought of as the ‘encasing’ for all these layers.
If you’re curious, the other major-player in the shell game is ‘bash’ (short for ‘Bourne-again Shell’). Bash has been around since the 1980s and still is used today in Unix-based systems like Mac and Linux.
Because shells are an interface, not just a ‘language’ of code. You can write complex programs in other languages like C++ or Python, then use your computer’s shell to call and execute those programs. So to take my “creating 100 folders” example from earlier- you could write a PowerShell script that executes 100 programs in a certain order, or at a certain time, or under specific conditions.
At a glance:
Still here? My goodness. Well. That’s the stuff I would say, if ever asked by a particularly persistent and curious person about PowerShell.
…if you really want to delve into it, I’ll go deeper here.