Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Powershell 4n00bs Sample

Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

Don Jones’ PowerShell

4N00bs
Don Jones
This book is for sale at
http://leanpub.com/powershell-4n00bs

This version was published on 2018-09-20

This is a Leanpub book. Leanpub empowers authors and


publishers with the Lean Publishing process. Lean
Publishing is the act of publishing an in-progress ebook
using lightweight tools and many iterations to get reader
feedback, pivot until you have the right book and build
traction once you do.

© 2018 Don Jones


Tweet This Book!
Please help Don Jones by spreading the word about this
book on Twitter!
The suggested tweet for this book is:
I’m reading #PowerShell4N00bs to bring #PowerShell into
my career! http://leanpub.com/powershell-4n00bs
The suggested hashtag for this book is #PowerShell4N00bs.
Find out what other people are saying about the book by
clicking on this link to search for this hashtag on Twitter:
#PowerShell4N00bs
Also By Don Jones
The DSC Book
The PowerShell Scripting and Toolmaking Book
Become Hardcore Extreme Black Belt PowerShell Ninja
Rockstar
Be the Master
Don Jones’ The Cloud 4N00bs
Instructional Design for Mortals
How to Find a Wolf in Siberia
Tales of the Icelandic Troll
PowerShell by Mistake
The Culture of Learning
for the wonderful, supportive, and friendly PowerShell
community who’ve been my friends, colleagues, and
inspiration since 2006.
Contents

1. About this Series . . . . . . . . . . . . . . . . . . . . 1

2. A Note on Code . . . . . . . . . . . . . . . . . . . . . 3

3. What is PowerShell? . . . . . . . . . . . . . . . . . . 4
What Came Before . . . . . . . . . . . . . . . . . . . . 6
Introducing PowerShell . . . . . . . . . . . . . . . . . 10
OK - Why Should I Care? . . . . . . . . . . . . . . . . 14

4. Installing PowerShell . . . . . . . . . . . . . . . . . 17
Windows PowerShell . . . . . . . . . . . . . . . . . . 17
PowerShell Core . . . . . . . . . . . . . . . . . . . . . 17
VS Code . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5. Your First Console Experience . . . . . . . . . . . . 18


Launch PowerShell . . . . . . . . . . . . . . . . . . . . 18
Check Your Version . . . . . . . . . . . . . . . . . . . 18
Run a Command . . . . . . . . . . . . . . . . . . . . . 18
Files and Folders . . . . . . . . . . . . . . . . . . . . . 19
Exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
A Good First Step . . . . . . . . . . . . . . . . . . . . . 19

6. Where Do Commands Come From? . . . . . . . . 20


Built-In Commands . . . . . . . . . . . . . . . . . . . 20
Comes with Software . . . . . . . . . . . . . . . . . . 20
CONTENTS

The Internet . . . . . . . . . . . . . . . . . . . . . . . . 20
PowerShell Gallery . . . . . . . . . . . . . . . . . . . . 21
Your Own Gallery . . . . . . . . . . . . . . . . . . . . 21
Seeing What Modules and Commands You Have . 21
What’s in a Module? . . . . . . . . . . . . . . . . . . . 21
Explore What’s Out There . . . . . . . . . . . . . . . 21

7. How Do I Use This Thing? . . . . . . . . . . . . . . 22


Windows Only: ExecutionPolicy . . . . . . . . . . . 22
It’s Okay to Ask for Help . . . . . . . . . . . . . . . . 22
Reading the Help Files . . . . . . . . . . . . . . . . . . 23

8. Objects and the Magic of Formatting . . . . . . . 24


Formatting Rules . . . . . . . . . . . . . . . . . . . . . 24
Messing with Objects . . . . . . . . . . . . . . . . . . 24
PowerShell Plays Along . . . . . . . . . . . . . . . . . 25
Objects: the Important Bits . . . . . . . . . . . . . . . 25

9. Enter the Pipeline . . . . . . . . . . . . . . . . . . . . 26


Six Pipelines . . . . . . . . . . . . . . . . . . . . . . . . 26
Simple Pipeline Examples . . . . . . . . . . . . . . . . 26
Pipeline Input: Plan A . . . . . . . . . . . . . . . . . . 26
Pipeline Input: Plan B . . . . . . . . . . . . . . . . . . 27
Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . 27

10. Filtering and Selecting . . . . . . . . . . . . . . . . . 28


Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Being Efficient with Filtering . . . . . . . . . . . . . 28
Selecting Properties . . . . . . . . . . . . . . . . . . . 28
Advanced Selecting . . . . . . . . . . . . . . . . . . . 29
Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . 29

11. The Very Basics of Scripting . . . . . . . . . . . . . 30


Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . 30
CONTENTS

12. Going Remote . . . . . . . . . . . . . . . . . . . . . . 31


Enabling Remoting . . . . . . . . . . . . . . . . . . . . 31
Connectivity . . . . . . . . . . . . . . . . . . . . . . . . 31
Sending Remote Commands . . . . . . . . . . . . . . 31
Remote Jobs . . . . . . . . . . . . . . . . . . . . . . . . 32
Wrapping Up . . . . . . . . . . . . . . . . . . . . . . . 32

13. Understanding Your OS . . . . . . . . . . . . . . . . 33

14. The Chapter of Gotchas . . . . . . . . . . . . . . . . 34


Format to the Right . . . . . . . . . . . . . . . . . . . 34
ForEach vs. ForEach vs. ForEach . . . . . . . . . . . 34
Collections vs. Objects . . . . . . . . . . . . . . . . . . 34

15. Where to Next? . . . . . . . . . . . . . . . . . . . . . 35

16. Welcome to the Community! . . . . . . . . . . . . . 36


1. About this Series
It’s always frustrated me that, as technology marches on
and becomes more complex, we seem to forget that there’s
this thing in the world called a “birth rate.” Although we
constantly have new people being born, growing up, and
entering the field, books and other learning materials tend
to drop the “total beginner” content over time, focusing on
more and more complex and high-end content. So where are
the newcomers supposed to learn stuff?
Thus, this series. This is the kind of “evergreen” content that
I suspect will change little over time. This isn’t a book for
someone who’s already covered the basics, and it isn’t a book
for someone looking to become an expert. This is a book for
someone interested in getting started, in understanding the
core concepts and tasks needed to begin using a technology.
It’s a book for the “easy stuff” that other experts are bored of
talking about.
As I work with other authors to create this content, and
as I write myself, my goal is to keep the tone casual and
conversational. I want to make this “easy stuff” truly easy for
you, the reader, to ingest and understand. I want try and give
you clear guidance on where to go next, and on what to expect
as you go there.
If you’re a more-experienced person reading this, you may
notice that some of the analogies and comparisons are differ-
ent from what you’re used to. That’s because, for the intended
audience of this book, I’m not relying on them having an
About this Series 2

existing knowledge base of the technology to build upon;


we’re starting from scratch, here, and so I’ll be using examples
and analogies that are appropriate to that mission. I truly want
anyone who is familiar with perhaps nothing more than a
smartphone to be able to pick this up and do well with it.
I hope you enjoy.
Don Jones, series creator
2. A Note on Code
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
3. What is PowerShell?
If you’ve used any kind of computer, even that “pocket
computer” you call a phone, then you probably have a good
idea of how computers work. You click (or tap) icons, you
type text into text fields, you drag stuff with a mouse or
your finger, and so on. Easy. In the computer world, that’s
called using a Graphical User Interface, although most of us
geeks would call it a “GUI” (pronounced, “gooey,” like melted
chocolate). GUIs are great. Almost anyone can pick up a
modern computer and start using it right off the bat, because
GUIs kind of make it easier to figure out what you need to do.
The same principle applies if you’re working with the bigger
computers that run networks, power the Internet, and un-
derpin the cloud. Called servers (because they “serve up the
goods” to your “client computer”), these expensive machines
need people to configure them, install software updates, add
new applications, and so on, and GUIs have always made
that easy. Need to install updates? Just click the “Updates”
button! Easy! Need to change a piece of configuration infor-
mation, like the network address the computer is reachable
at? No problem! Go into the Settings app, click on “Network
Settings,” and type the correct address into the text box. Easy!
Where GUIs suck is scale. Scale is a big thing in the computing
industry, and it basically means, “how large can this thing get
before it becomes a problem?” Elementary school classrooms,
for example, don’t scale well. Stick 20 kids in a class and
you’re probably fine. 25 might be pushing it. 30 starts to feel
What is PowerShell? 5

like a bit too much. By 50, it’s all fallen apart and the kids are
trying to eat each other, because they’ve already eaten the
teacher.
Scale is important in all kinds of industries. Take cars, for
example. Back in the day, before good old Henry Ford came
along. Cars were put together by hand. That didn’t scale well.
If it took 5 guys to build a car, and you wanted to build 10 cars
at once, you needed 50 guys. If you wanted 20 at once, you
needed 100 guys. Eventually, you ran outta guys. But Henry
built machines, so that a car could be built by 2 guys using
all the machines — and faster, too! And those same 2 guys
could build cars all day! Henry increased his scale through
automation.
GUIs are a bit like those 5 guys building 1 car. If it takes you
5 minutes to complete a task, then it’ll take you those same 5
minutes every time you need to perform that task. If you do
that task 70 times a day, that’s pretty much all you’re going to
be doing all day. If the business needs that task performed 150
times, you’re either going to be putting in a lot of overtime or
hiring a friend. And you’re both going to end up really bored,
doing that same task over and over and over and over and
over.
So PowerShell is the Henry Ford of computer administration.
Instead of clicking buttons and dragging things, you write
down what you want the computer to do. You write it down
in a kind of language that both you and the computer can
understand. Then, when you need the task performed, you
just basically point to those instructions, and the computer
does it. It does it faster than you, and more reliably, because
it never gets bored of doing the same thing over and over and
over and over.
What is PowerShell? 6

What Came Before


This idea of writing down instructions isn’t new. Basically,
that’s what programming is, although when it comes to
computer administration, we’re talking a super “lightweight”
kind of programming, often referred to as scripting. Because
it’s like a movie, right? In a movie, the script tells the actors
what to say, and often how to move around the set. Computer
scripts are the same thing - they tell the computer what to do.
Back in the old days, writing down instructions was the
only way to tell a computer what do to. GUIs didn’t come
along, in the server world, until the mid 1990s, and didn’t
become really common until the late 1990s and early 2000s.
Prior to that, everyone just typed whatever they wanted the
server to do. Being humans, and being so much better than
these mere machines, we typed in commands. Commands told
the computer what we wanted to do, much like you might
command a dog to sit or roll over. You typed these commands
into a special app called a Command-Line Interface, or CLI.
See, it’s like the opposite of a GUI. They’re both interfaces, or
ways of telling a computer what to do; one of them involves
typing commands one at a time, and the other involves poking
around graphical icons and such.
But commands had two very serious problems, which got
worse and worse over time. These are important problems
to understand, because they’re the two of the exact three
things PowerShell was created to solve. And it’s also worth
mentioning that puh-lenty of people don’t think these are
problems, because they’ve been working with these problems
for so long that they’re just used to it. It’s like how you never
realized how awesome air conditioning was until the first
What is PowerShell? 7

time you experienced it, and then you’re like, “um, no, I’ll stay
inside all summer, thanks.” But seriously, lots of folks working
on computers don’t even think these things are problems,
but I’ll try and make a case that they are, indeed, big bad
problems.

Problem One: What Does This Mean?


The first problem is that the commands themselves are weirdly
named, weirdly formatted, and really hard to remember until
you’ve been working with them for a decade or so. Like, the
learning curve on a common CLI is massive. It’s people who
learn this stuff when they’re in college (when your brain is
still spongey) and keep doing it all their lives who love these
commands; nobody else does. Check it out:

1 ps -A | grep httpd | xargs -n1

Clear as mud, right? That’s the “language” you had to learn


to tell a computer what to do, and in many, many, many
places, that’s still how you do it. The fact that this is a problem
doesn’t mean people don’t still do it! But this is a problem
because it makes it really hard for someone else to get into
the industry. We realize how that sort of provides job security
for the people already in it, but it’s terrifying for businesses,
who worry that their 60 year-old server admin will leave or
die, and they won’t be able to find someone else to manage
everything.

Problem Two: Connecting Dots


Let’s take a look at that command-line example again:
What is PowerShell? 8

1 ps -A | grep httpd | xargs -n1

Now, we want to explain this, because there’s an important


thing going on, but don’t feel you need to learn this. What’s
happening here is a command called ps, which gets a list of
all the apps the computer is currently running. The -A part
is a flag, or switch, which flips the command to a specific
behavior. In this case, it means we want to see all the apps
(called processes) running on the computer.

Next, you see a pipe character: |. This means that


we don’t want to actually see the output of the ps
command. Rather, we want to pipe it to the next
command, named grep. Think of this as a literal
pipe, like a piece of plumbing, connecting the “out”
of the first command to the “in” of the second
command. So the grep command sucks in all the
process information, and it looks for lines of text
containing httpd, because that’s what we told it to
do. Only those lines get “out” of grep, and they’re
piped, in turn, to the xargs command, which does
something else with the information.

The pipe is the important part, here. It’s the idea that one
command’s output can be used by another command. String-
ing them all together lets us achieve some powerful results,
such as shutting down just the process named httpd, which is
what the above command-line does. The problem here is that
traditional commands just produce these enormous wedges
of text as output. For example, here’s a bit of what ps outputs
if you just run it by itself:
What is PowerShell? 9

1 PID TTY TIME CMD


2 5763 pts/3 00:00:00 zsh
3 8534 pts/3 00:00:00 ps

Charming stuff, right? In reality, almost no other command


can do anything with that output as-is. That’s why you almost
always wind up having to manipulate it, using commands
like grep, sed, and awk, before sending it on to another
“real” command. And incidentally, I’m picking on the Linux
operating system here, but Windows and other operating
systems are guilty of the exact same thing in their own CLIs.
And here’s the real bummer: suppose you’ve spent time devel-
oping a command-line that is really sweet. You’re running a
command, grabbing its output, looking for specific characters
in columns 30 through 35 of each line, and for the lines
that match what you want, you’re outputting just column 1
through 5, and then sending that on to another command to
do something with the info. It’s slick, it took a long time to
get right, and you’re ready to go.
Then someone updates your operating system and the first
command’s output changes. It’s in a different order. Maybe
the new order is prettier on the screen, but it absolutely
broke that sweet command-line you spent so long creating.
DAMMIT!
The reality is that most operating systems try to make sure
this never happens, which is a shame. Here’s what they’ll do
instead:

• Never change any command. Instead, make new com-


mands, with equally obscure names, and have those do
whatever new thing we want.
What is PowerShell? 10

• Create switches that you have to use to get new output


or new features. That way, the command can continue
working as-is, but you can “switch” its behavior to some-
thing else. This is why the ps command has eleventy-
dozen switches for you to remember!

Both of these are poor solutions, because they just add to the
amount of information everyone has to remember.

Introducing PowerShell
First, we should get some terminology right.
In 2006, Microsoft introduced Windows PowerShell 1.0. Through-
out the next decade, they released new versions of Windows
PowerShell: 2.0, 3.0, 4.0, 5.0, and 5.1. Good times!
But for version 6, Microsoft took a different tack. In 2017,
they released the first version of PowerShell Core, or just
“PowerShell,” with no “Windows” attached. It’s technically
version 6, but it’s the first version that runs on Windows,
Linux, and macOS. It’s a bit trimmed-down from its Windows
cousin. And, at the same time, Microsoft announced that
Windows PowerShell would basically stop at version 5.1.
Plain-old PowerShell (more properly, “PowerShell Core”) is
the go-forward product, and that’s what this book is about.
From its beginning, though, PowerShell was designed to
solve three problems, two of which are the ones I’ve already
introduced you to.

Solution 1: Consistency
PowerShell’s first step was to take all the weird command
names and ditch ‘em. Instead, PowerShell defines a naming
What is PowerShell? 11

pattern for its commands which is English-based, much more


verbose than grep or ps, and in which the commands’ names
more clearly imply what the command does.
PowerShell commands consist of two parts: a verb and a noun.
The verb part comes from a fairly short, preapproved list of
verbs. That way, you can start to see the consistency in the
naming, and get used to it quickly. Commands that create
a new thing, like a new user account or a new file, use the
verb New (never “Create,” or “Instantiate,” or anything else).
A command that retrieves information uses the verb Get. As
you progress through this book, you’ll meet a few of these.
The noun part is always singular, and tells you what the
command is acting on. So a command that creates new users
in Microsoft’s Active Directory system would be New-ADUser
(not ADUsers, which is plural, even if the command is actually
capable of creating more than one). A command that launches
an app might be called Start-Process. If you’re not familiar
with computers from a behind-the-scenes perspective, the
nouns can take a little getting used to, but it’s worth the effort.
A> You know, as a note, I’m always telling people that
PowerShell itself is pretty easy to pick up. It’s the technologies
PowerShell touches that get hard. Like, if you want to use
PowerShell to do stuff in Microsoft’s Azure cloud, it’s the
Azure stuff that’s hard to grasp. Once you have that in your
head, the PowerShell bits are easy.

Solution 2: Structured Data


PowerShell’s second innovation was to ditch the textual out-
put of commands. Oh, PowerShell can still dump a lot of text
to the screen, and we’ll talk about how it does that a bit later.
What is PowerShell? 12

Instead, PowerShell commands output a kind of structured


data. If you’ve ever seen an Excel spreadsheet, you can think
of PowerShell’s structured data as a bit like that. Each line
of command output becomes a row in the spreadsheet. The
various bits of information on each line get broken out in to
the spreadsheet’s columns.
The advantage of this approach is that you don’t need to fuss
with all the particulars of text. There’s no more, “I need to
find lines where the characters httpd show up in columns
30 through 35; instead, you just tell PowerShell “I need all
the rows where the Name column contains httpd, please.” It
doesn’t matter if the command changes in the future and the
Name column moves from 3rd place to 6th place; PowerShell
can simply track it down by using the column’s name.
The structured data approach, in real-world conditions, can
shave off 90% of the time spent constructing complex com-
mand lines. It’s that big a deal, and as we move through this
book you’ll see how easy it is to work with.

Solution 3: Admin-Friendly
There’s another problem that isn’t specific to traditional CLIs.
See, the fact is that Windows, Linux, and other operating
systems already have all the tools you need to perform almost
any task you might need. But most of those “tools” are really
designed for software developers, and they’re built in a way
that is comfortable and familiar to software developers, but
often confusing and antagonistic to anyone else. For example,
Windows has the ability to terminate a running app. All you
have to do is run code like this:
What is PowerShell? 13

1 System.Diagonstics.Process p =
2 New System.Diagnostics.Process()
3
4 p.GetProcessById(1234)
5 // assumes you know that 1234 is the app you want
6
7 p.Kill()

Easy, right? Well, if you’re a developer, it’s very easy. All you
do is type in that code, compile the code into an executable,
and run the executable. Takes maybe 10 minutes.
PowerShell would just want you to do this:

1 Stop-Process MyApp

Internally, it’s that same code running! See, PowerShell isn’t


actually a new tool. It doesn’t have new capabilities. All
PowerShell does is take the capabilities the operating system
already has, and “wrap them up” into an easier-to-use pack-
age that you can just type and run, right from PowerShell’s
CLI app. So PowerShell is potentially as powerful as your
entire computer and every piece of software running on it,
because PowerShell can turn almost any functionality into a
more consistent, structured-data, command.
This is why PowerShell - which, remember, started in the
world of Windows - has so much applicability in the worlds of
Mac and Linux, as well. PowerShell isn’t trying to “subvert”
their native functionality, and it’s not trying to make anyone
learn an all-new set of tools that work differently. PowerShell
is just like a “translation layer.” The same Start-Process
command can be used on Linux, Mac, or Windows; internally,
it’ll do slightly different stuff on each of those operating
What is PowerShell? 14

systems in order to make the command actually happen. But


it handles all of that inside itself; as a user of PowerShell,
you just need to know the one, easy-to-remember, English-
like command name.

OK - Why Should I Care?


Do you know how an economy grows? Like, the economy of
a country?
It works a bit like this: suppose you manufacture widgets. You
have a machine that does it, and it costs about $1 per widget
to make them. Your machine can make about 1,000 a day.
You decide to buy a second machine. Same kind - about 1,000
a day, and about $1 apiece. Have you grown the economy?
No. You’re producing more, but that’s because you’re putting
more into the system, too: the machine itself, plus whatever
raw materials widgets are made of.
Now suppose you decide to replace both machines with a
newer, better one. This one can make 4,000 widgets a day,
and they now cost $.90 to make, but you can sell them for
the same price. You have grown the economy. For the same
given input in raw materials and capital investment, you’re
producing more, for less. That’s how economies grow.
Businesses are almost genetically programmed to grow in
this way - produce more, for less. You can’t just do this by
keeping a close eye on paperclips, though. Reducing your
costs by a small fraction isn’t growing the economy, it’s
reducing your costs a bit. True economic growth usually
requires automation. Ah, you perhaps see where this is going.
What is PowerShell? 15

You see, managing servers is no different than any other kind


of work that companies might do. If a company spends $x
managing a server, then it can only grow its economy by
spending less to manage even more servers. If you’re man-
aging servers by clicking around in a GUI, as we’ve already
noted, you’re never going to achieve the level of efficiency
needed to grow the economy. And that’s where automation
comes in. If you can automate server management, then
fewer inputs (administrator people) can produce more output
(manage more servers), and that’s economic growth.
PowerShell isn’t the only way to automate server adminis-
tration. But, as we pointed out in this chapter, PowerShell
solves many of the problems that other techniques have
introduced, so it’s arguably more efficient than other, older
automation techniques. More efficient means a bigger boost
to the economy, and PowerShell’s often easier to learn, to
boot.
Let’s assume you work in the server management business,
and that you’re paid $50,000 a year (a nice round number,
because I’m terrible at math). Your “fully loaded” salary -
including benefits, payroll taxes, and so on - is about 40%
higher, or about $70,000 (this is in the US; outside the US, the
number is probably quite different, and you’d need to ask an
HR specialist for your particular country’s fully loaded salary
multiplier). Divide that by 2,000, which is about the number
of working hours in a year, for an hourly rate of $35.
Now suppose you have a task that you have to complete
all the time, and it takes ten minutes. Therefore, that costs
your employer about $5.83 every time you do it. If you
spent an hour setting PowerShell up to perform that task,
it’d cost you a one-time charge of $35, and then the task
would essentially cost nothing to perform in the future. After
What is PowerShell? 16

PowerShell performed the task just six times, you’d have paid
off your investment, and every time PowerShell performed
the task after that, you’d be growing the economy. Work would
be happening, essentially for free. That’s how Henry Ford did
it, and that’s why you should care about PowerShell. The
first line on your resume should be, “Dedicated automation
specialist who, in one year, saved former employer $100k [or
whatever] in labor costs.”
Keep a log of what you automate. Figure out how long the task
took to perform manually, and about how many times a year
it was performed. Track the time it took you to automate it.
Figure out the money you saved, and add that to your resume
statement.
That is why you should care about PowerShell.
4. Installing PowerShell
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Windows PowerShell
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

PowerShell Core
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

VS Code
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
5. Your First Console
Experience
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Launch PowerShell
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Check Your Version


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Run a Command
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
Your First Console Experience 19

Files and Folders


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Exit
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

A Good First Step


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
6. Where Do
Commands Come
From?
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Built-In Commands
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Comes with Software


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

The Internet
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
Where Do Commands Come From? 21

PowerShell Gallery
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Your Own Gallery


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Seeing What Modules and


Commands You Have
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

What’s in a Module?
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Explore What’s Out There


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
7. How Do I Use This
Thing?
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Windows Only: ExecutionPolicy


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

It’s Okay to Ask for Help


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Update Help
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
How Do I Use This Thing? 23

Finding Commands and Help


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Online Help
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Reading the Help Files


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
8. Objects and the
Magic of Formatting
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Formatting Rules
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Try These
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Messing with Objects


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
Objects and the Magic of Formatting 25

PowerShell Plays Along


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Objects: the Important Bits


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
9. Enter the Pipeline
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Six Pipelines
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Simple Pipeline Examples


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Pipeline Input: Plan A


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
Enter the Pipeline 27

Pipeline Input: Plan B


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Wrapping Up
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
10. Filtering and
Selecting
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Filtering
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Being Efficient with Filtering


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Selecting Properties
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
Filtering and Selecting 29

Advanced Selecting
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Wrapping Up
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
11. The Very Basics of
Scripting
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Wrapping Up
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
12. Going Remote
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Enabling Remoting
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Connectivity
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Sending Remote Commands


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
Going Remote 32

Remote Jobs
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Wrapping Up
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
13. Understanding
Your OS
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
14. The Chapter of
Gotchas
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Format to the Right


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

ForEach vs. ForEach vs. ForEach


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

Collections vs. Objects


This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.
15. Where to Next?
This book was never meant to be your complete PowerShell
journey. In fact, Don has an entire page¹ that kind of outlines
the journey.
Our recommendation from here is to pick up a copy of Learn
Windows PowerShell in a Month of Lunches. It’s a more in-
depth version of some of what’s in this book, along with
a lot_more. It’s got formal exercises that kind of guide you
through the shell’s learning journey in a deeper fashion.
It’s specific to _Windows PowerShell, of course, but 90%
of the book is applicable to PowerShell Core, too. You’ll
find it at http://Manning.com (which is the only place to
buy electronic-only versions), or through Amazon and other
booksellers (and all print versions contain a voucher for free
electronic editions).
¹http://DonJones.com/powershell
16. Welcome to the
Community!
This content is not available in the sample book. The book can
be purchased on Leanpub at http://leanpub.com/powershell-
4n00bs.

You might also like