Some time ago I dug deep inside myself and thought about which area is my strongest. I came to the conclusion that explaining complex things in a very simple way is one of my qualities. I’ve heard that a lot from my students. Explaining complex things in a simple way is what beginners need.
What the lecturer needs is talent, empathy and skill. Empathy is the most important thing. You need to be able to put yourself in the learner’s shoes, you need to remember how you dealt with the subject for the first time and what problems you encountered. Remember that most of the time, your students will encounter the same problems. And you need to focus on these. All these gave me the idea to write a series: PowerShell for Beginners. And this is the first part. Let’s dive in. We’ll start at the very beginning …
When I started to notice that there is a new command line or something like that, I asked myself: Why? Why learn a new command structure now and what the hell is it for? There are many reasons:
- IT is focusing more and more on automation
- The significance of the graphical user interface for IT-Pros is decreasing
- Server Core is out
- Nano Server is out
- IOT is coming
These things are not quite there yet. They’re coming up. You don’t really believe that administrators of the future will waste their time with creating new users graphically in an onboarding process? You won’t believe that Microsoft will consider a 12 GB operating system with a fully graphical user interface as the future? In the future, everything will revolve around automation and small and secure operating systems. This are the topics for the next years. And it affects IT-Pros as well as Developers.
That’s what I believe.
You can think of it as a natural law: The less software installed on the system, the fewer updates are needed, the fewer errors occur because less software is installed. With a graphical user interface, this is hardly feasible.
If you are satisfied with being like most of the other administrators (creating users graphically, buying a small tool for each new project) then this series is not the right one for you. If you want to be different, be more future-oriented and help your colleagues out of their dilemma ;-), stay tuned. It’s starting right now. What have we learned in this section (ok, the hint was something hidden):
PowerShell is a professional automation scripting language for Windows and (coming up soon) Linux. Automation is the future. Therefore PowerShell is the right tool for Windows Administrators.
Enough said. Now it’s time to come to the main part. PowerShell itsself. Let’s snuck in.
Where do I find the “new” PowerShell Console?
First of all I would like to mention that PowerShell is by no means new. But this is another thing, and there’s no room for this here. For my readers PowerShell is new and that’s what counts.
All you need is a Windows system. Later on Linux 😉 Best Windows 10 or Windows Server 2016. Why? Because PowerShell has been updated regularly in the last few years. And in this series it makes sense to use PowerShell 5.0, because I also use it. But it’s not a broken leg if you use Windows 7 or Windows 8. I try to be backwards compatible.
Windows 7 | 8 | 10
In Windows 7,8 and 10 PowerShell is something hidden and one way to find it is the built-in Windows search.
Open the best match and you’re in!
Don’t worry if your screen deviates a little from mine. I’ve prepared PowerShell a little bit for my purpose. Your screen should look like this:
That’s the normal behavior. When PowerShell starts the starting point is set to the user’s profile.
I recommend to pin PowerShell to your taskbar. Right click Best Match and select Pin to taskbar.
Windows Server operating systems
Usually PowerShell is already stored in the taskbar of most server operating systems. If not, follow the procedure above.
Are there differences between the Server and the Client?
Yes, there are differences. When it comes to services and software Windows Server operating systems offer more PowerShell commmands. For example you can install Active Directory Domain Services only on server systems. Active Directory brings in it’s own PowerShell commands. The fact that you cannot install AD on a client operating system means that you have a greater variety of commands on Windows Servers. But there’s a little workaround which is called Remote Server Administration Tools (RSAT). Maybe we will discuss this at a later post of this series.
For my readers it is more important to know that for this part it doesn’t matter whether you are using a Windows client or a Windows server.
What have we learned so far?
PowerShell can be found by using the Windows Search. On most Windows Server operating systems PowerShell is already pinned to the taskbar. There are slight differences between PowerShell on Servers and Clients.
Customizing the console
I have decided not to write too much about this topic. There are many ways to customize the console. One way is to open PowerShell and right-click on the small upper part of the window. Select Properties. As you can see, I use enlarged fonts. This is quite helpful for the screenshots of my blog.
More information can be found here:
Your first command
As the headline promises, we are now going to enter and execute our first command in this first part of the series. All of you have already shut down a computer. I hope so. Well, PowerShell follows a philosophy. This philosophy will be the subject of the next contribution to the series. For now all we need to know is that there’s a verb and a noun.
For shutting down your computer the verb is stop and the noun is computer. You want to shut down your computer, which means you want to stop your computer. So the command is Stop-Computer.
And to make sure you don’t actually shut down the computer, we’ll add the parameter whatif. This ensures that the computer does not shut down, otherwise you will not be able to read this article to the end 😉
Open Windows PowerShell with administrative privileges (If you’ve followed the proposal above you’ll find PowerShell in your taskbar).
As you can see nothing has happend. PowerShell tells you what will happen if you shut down the computer. It will perform Stop-Computer on the localhost. By the way: The Parameter whatif is available for all commands.
What have we learned so far?
Each PowerShell command consists of a verb and a noun. Stop-Computer shuts down the computer. If you use the parameter WhatIf then the computer don’t actually shut down. WhatIf is available for all commands.
Shutting down the computer
Promise me one thing: Today when you shut down your computer, you will do it in PowerShell.
The Force Parameter instructs the command to shut down the computer even other people are logged on.
Code of Practice
I already have a code of practice for my series. I will repeat this code again and again. It’s called:
Do it yourself. Anything you don’t do yourself will soon be forgotten.
Which brings me to the next part. It’s about doing it yourself.
The exercise up to the next part is:
Find out the parameter to ask for confirmation before shutting down the computer.
(Tip: Type Stop-Computer – and then press TAB). The solution can be found in the next article, but I think you will find it out yourself 😉 Remember the code of practice!
See you next time at the article “PowerShell for Beginners (Part 2): The Philosophy Verb and Noun.
Patrick Gruenauer, MVP PowerShell