►
From YouTube: PSS: PowerShell 101 Arrays with Wes Carroll
Description
PowerShell Saturday is a training event for all things PowerShell. The event was held in Raleigh, North Carolina and hosted by Research Triangle PowerShell User Group.
Wes Carroll teaches you the basics with this Array 101 talk. This is a great talk for beginners to learn a bit more about the core constructs within PowerShell
The files for Wes's slides and code can be found on our github page:
https://github.com/rtpsug/PowerShell-Saturday/tree/master/2019-NC.State/
B
A
Recordings
begun,
thank
you
all
for
being
here,
PowerShell
101
we're
going
to
be
talking
about
a
raise
today
before
we
get
started
number
one.
Thank
you
to
our
sponsors.
Without
them,
we
won't
have
this
opportunity
to
get
together.
So
that's
a
really
important
go
outside
you
know
say
thank
you
see
if
they
can
help
you
out
in
any
way
number
two.
Thank
you
to
you
guys
without
you
giving
up
your
Saturday
to
be
here.
You
know,
none
of
us
would
be
able
to
learn
more
Network
figure
out
who's
who's.
B
A
In
this
world
of
PowerShell,
Who
am
I,
so
my
name
is
Wes
Carol
I'm,
an
Enterprise
Architect
at
zurdo.
We
are
going
to
cover
absolutely
nothing
having
to
do
with
zero.
Today,
it's
all
going
to
be
PowerShell
I've
got
about
20
years
of
experience
in
the
information
technology.
Space
I've
always
been
working
with
PowerShell
since
about
2012
when
I
started
using
it
in
anger,
you
can
connect
with
me
on
LinkedIn,
that's
probably
where
I
spend
most
of
my
time
more
time
than
I
really
should
github,
I'm
just
w
carroll
on
github.
A
If
you
guys
are
looking
to
get
into
powershell,
I
highly
recommend
going
out
to
github
checking
out
what
they
have
for
powershell
projects.
I
think
they're
calling
october
is
coming
up
here.
What
digitalocean
they're
going
to
be
a
lot
of
PowerShell
projects
that
you
guys
can
get
involved
in
good
for
beginners?
If
you
guys
get
started
with
that
sign
up
on
digital
oceans
website,
they'll,
send
me
a
shirt
with
four
pull
requests.
I
think
it
is
but
go
out
and
check
it
out.
My
email
is
w
Carol
at
Ocean,
Beach
life.
A
That's
a
story:
we
can
get
to
it
another
time
and
then
I
am
on
Twitter
at
West
Carroll
tech,
because
apparently
there
are
a
lot
of
West
Carol's
out
there.
So
what
is
it?
A
ray
I
mean
we're
literally
going
to
start
at
the
basics
here
right.
An
array
is
that-
and
this
is
a
formal
definition.
An
array
is
a
data
structure
that
is
designed
to
store
collection
of
items
when
I
say
formal
definition.
A
If
you
do
get
help
about
arrays,
that
is
the
definition
that
up
these
items
can
be
of
the
same
type
for
different
types
or
they
can
be
strongly
typed,
meaning
when
I
declare
my
array,
I
can
say,
my
array
is
only
going
to
contain
strings
or
integers
or
whatever
you
want
it
to
be,
we'll
get
into
another
way.
That
arrays
can
be
strongly
typed
and
may
need
to
be
strongly
typed
a
little
bit
later.
A
But
something
very
important
to
understand
is
that
the
array
size
or
the
array
count,
the
number
of
objects
in
an
array
is
established
when
the
array
is
initialized.
This
is
immutable.
It
cannot
be
changed
something
just
to
kind
of
keep
in
your
mind
as
we
go
along
and
then
each
item
is
assigned
to
static
index.
The
way
I
like
to
think
about
an
array
is
like
a
shopping
list
right,
you
say
well,
the
first
thing
I
mean
is
bread.
Second,
eggs
thirds,
milk
right.
Everything
has
a
number.
A
Each
item
has
a
number
and
it's
got
something
associated
with
it,
where
arrays
used
they're,
literally
used
everywhere
in
PowerShell,
they're,
so
prevalent
that
even
when
you
create
a
variable
and
you
store
a
line
of
text
or
a
string
in
it.
What
PowerShell
does
in
the
background
is,
it
will
actually
assign
an
index
to
every
character
in
that
array,
and
then
you
can
call
that
index
in
order
to
get
just
that
character,
so
yeah,
so
that's
without
strings.
A
The
other
way
that
you
can
use
it
is
when
you
use
a
command
line
when
you
use
a
command
like
get
process.
What
happens
is
is
that
and
store
it
in
generally
and
when
that
happens,
it's
going
to
create
that
process
as
this
base
type
system
array,
this
base
type
is
what
the
array
is
built
on,
but
you
can
see
it's
built
on.
The
parent
object
object
right,
because
everything
in
PowerShell
is
an
object.
A
So
how
do
I
create
an
array?
Well,
the
first
way
to
create
an
array
is
really
simple:
create
a
variable
set
it
equal
to
@
symbol,
open
friends,
close
friends
that
creates
an
empty
array.
When
we
do
this,
when
you
create
array
it
has
properties
inside
of
it.
Just
intrinsically
that
comes
with
that
type,
and
one
of
those
is
a
method
called
get
type.
So
we
can
see
that
we're
using
that
here
again
it
is
an
array,
but
that's
kind
of
useless.
That's
an
empty
array!
There's
nothing
in
there.
A
It's
just
a
variable,
that's
taking
up
space
in
your
memory.
So
how
do
we
make
it
more
useful?
Well,
what
we
can
do
is
we
can
start
to
add
items.
So
I've
got
my
first
item.
My
second
item,
my
third
item,
then
I've
got
number
4
go
ahead
and
you
know
hit
enter
still
an
array
I've
mixed
my
types
here
out
of
the
system
array.
A
The
main
reason
why
you
would
see
people
use
this
or
there
are
another
option
in
order
to
use
this
is
when
you're,
actually
coding
and
you're,
creating
the
text
file
that
you
will
then
rename
to
dot
ps1
or
you
save
it
as
not
ps1
or
whatnot.
You
can
actually
create
an
array,
so
it
becomes
a
little
bit
more
readable
when
you
are
typing
it
out,
you'll
notice.
There
are
no
commas
separating
this.
When
you
create
an
array
like
this,
it
will
actually
with
that
carriage
return.
A
A
What
we
can
see
is
our
left
hand
side
as
y'all
are
looking
at
it.
I've
got
to
remember
that
it's
switched
so
over
there.
On
the
left
hand,
side
we
have
the
output
and
you'll
notice
that
it's
a
first
in
first
out
queue
right
order
matters
in
a
race.
The
first
item
that
you
put
is
always
going
to
be
the
first
item
in
the
array,
and
it
comes
out
in
that
right
order
or
in
that
exact
order,
but
this
isn't
really
useful.
A
It's
just
a
great
way
to
print
something
out
to
the
screen
and
if
that's
what
you're
using
it
for
fantastic,
but
you
can't
do
anything
with
it.
So
how
do
we
access
everything?
Well,
the
index
that
index
that
I
talked
about
that
one.
Two,
three,
four:
five:
when
we
go
ahead
and
we
set
the
variable
to
our
items
and
then
we
have
a
property
called
count,
so
every
variable
or
every
array
variable
has
a
property
called
count
and
count
will
tell
you
the
number
of
items
in
that
array,
and
it
comes
back
to
six.
A
The
problem
is:
is
that
you
and
I
learn
to
count
going
one.
Two:
three
computers
learn
to
count
going:
0
1
2.
So
what
you
have
to
understand
is
is
that
the
index
that
is
assigned
starts
at
zero.
It
always
starts
at
zero.
It's
never
not
going
to
start
at
zero,
and
the
last
item
is
always
going
to
be
the
count
of
the
array
minus
one
all
right.
So
if
we
ever
need
to
get
the
last
item,
we
can
say
all
right
how
many
items
there
in
the
array?
Six
great.
A
We
need
the
fifth
item.
How
do
we
actually
do
that?
Well,
still,
the
index
so
still
have
my
whiskies
and
in
this
case,
I
want
to
get
whisky
with
index
number
two.
So
in
order
to
access
that
item
in
there
I
call
my
variable
and
then
I
do
a
square
bracket.
The
number
of
the
item
close
square
bracket.
This
is
going
to
tell
powershell
that
hey
return.
The
item
that
is
index
number
two,
and
in
this
case
it
happens
to
be
Scotch.
A
A
So
when
we
actually
execute
that
it's
going
to
go
ahead
and
it's
going
to
return
rye,
single-malt
and
Canadian,
this
gives
us
a
little
bit
more
flexibility
in
calling
the
data
from
PowerShell
so
that
we
might
be
able
to
make
one
call
to
get
the
data
we
need
so
continuing
on
PowerShell.
It's
got
this
great
functionality
that
I
love
that
it's
gonna
work,
no
okay!
Well,
my
tricks
are
out
parcels
got
this
great
functionality,
number
dot
dot
next
number.
A
What
this
allows
us
to
do
is
this
allows
us
to
top
how
to
tell
PowerShell
look
I
want
a
range
of
numbers,
starting
at
this
number
and
ending
inclusively
at
that
last
number.
So,
when
I
call
this
actual
command
and
I
execute
it,
it's
going
to
return
three
items:
it's
going
to
return,
bourbon,
rye
and
Scotch
items
zero,
one
and
two.
B
A
That
to
that
later,
so
there
you
go
more
often
than
not.
So
this
is
another
cool
powershell
trick,
and
if
you
were
in
the
previous
session,
it
was
actually
used.
This
allows
us
to
again
set
the
array
and
do
negative
one
negative.
One
is
a
way
to
tell
powershell
look.
Give
me
the
last
item
in
the
array.
I
don't
know
how
many
items
I
have
I
just
know:
I
need
the
last
one,
so
we
choose
negative
one
and
when
we
execute
that
it
outputs
Canadian.
A
Mom
pace
so
that
negative
one
is
a
great
trick
to
understand.
Just
depending
on
what
you're
doing
look
look,
I,
don't
care
about
the
rest
of
it.
I
know
it's
all
an
array
I
just
want.
The
last
item
give
me
whatever
that
last
item
is,
but
we
can
do
the
same
tricks
that
we
have
with
the
positive
numbers.
We
can
give
it
a
couple
different
ones
in
a
rate
format
with
that
comma
and
get
not
just
the
last
item,
but
we
can
say
negative.
Three
and
I'll
start
counting
backwards.
A
So
if
Canadian
is
negative,
one
Irish
is
negative.
Two
single
malt
is
going
to
be
negative.
Three
in
this
case,
I
only
want
negative
one
in
negative
three,
so
I
get
my
Canadian
and
I
get
my
single
malt
again
with
the
range
I
want
negative
one
through
negative
three
I'm
going
to
get
Canadian
Irish
and
single
malt,
starting
with
negative
one
going
to
negative
three
or
I
can
mix
and
match.
You
know
we
talked
about
order.
Order
is
important
in
a
race
if
I
want
it
to
come
out
in
a
certain
order.
A
Powershell
is
going
to
parse
it
in
the
order
that
I
dictate
in
my
square
brackets,
so
we're
going
to
get
negative
one.
First,
Canadian
zero
bourbon
five
is
Canadian
again,
so
I
got
the
same
element
twice,
calling
it
two
different
ways:
I'm
going
to
apologize
for
how
fast
I'm
going
I
literally
have
53,
slides
and
I
cut
that
down
from
60.
So.
A
Again,
how
do
I
access
the
data
we
still
can
use
going
from
negative
1
to
negative
3
that
dot
dot
connotation
all
PowerShell
is
going
to
do?
Is
it's
going
to
count?
How
do
I
start
at
negative
1
and
how
do
I
get
to
negative
3?
Well,
I
gotta
go
through
negative
2,
so
we're
going
to
get
Canadian,
Irish
and
single
malt
the
same
way.
It
will
count
up
how
do
I
get
from
negative
3
to
1?
Well,
I
can
go.
A
Ok,
so
again,
I
have
my
whiskies
now,
when
I
set
it
to
a
variable.
Now,
I've
got
this
one
item
out
of
my
array
into
my
variable:
I
can
call
my
variable
and
it
comes
up
urban
same
thing
with
several
of
them.
So
again
my
comma
separated
value
I
go
0
to
3,
and
what
will
happen
is
is
that
it
will
assign
those
values
into
a
new
array.
A
I
didn't
do
a
get
type
on
this,
but
if
I
looked
at
favorite
again,
favorite
would
now
be
a
new
array
consisting
of
3
items,
and
in
this
case
they
would
be
re
indexed,
so
in
favorite
index
0
would
be
bourbon
index
1
would
be
Scotch
index.
2
would
be
single
malt.
But
in
my
fate
in
my
whiskey's
array,
all
those
indexes
would
remain
the
same,
so
they
become
two
different
objects.
At
that
point,.
A
In
fact,
if
I
did
yeah,
we
won't
get
into
it.
We
don't
give
it
okay,
so
the
other
one
thing
that
we
can
do
that's
really
cool
is.
We
can
actually
create
an
array
of
variables
set
that
equal
to
the
actual
array
and
then
what's
going
to
happen
is,
is
as
I
call
each
of
those
variables
first
is
going
to
get
the
the
first
item,
which
is
whiskey
or
index
0
or
its
bourbon
index.
0.
A
Second,
try
third
is
scotch,
and
then
it
takes
the
rest
of
the
array
and
it
assigns
it
to
the
last
one.
So
if
I'm
interested
in
you
know
like
the
first
two
items
and
I
want
to
create
an
array
that
has
everything
that
I
did
put
in
to
the
first
two,
this
is
the
way
that
I
can
do
it.
So
whiskey's
is
my
array
and
then
I
PowerShell
is
reading
through
that
way
array.
B
A
A
A
So
this
time,
I
only
want
the
three
right
or
yeah
I
only
want
the
three
I
want
the
first
second
and
last
so
I
create
that
those
three
variables
and
then
I
set
it
to
the
array.
I
use
the
indexes
that
I
want,
and
so
I
get
the
first
one,
the
second
one
in
the
last
one
right
in
this
case,
I
don't
need
the
rest,
because
I've
told
PowerShell
exactly
what
I
want
in
those
variables
all
right.
A
A
So
I
made
a
mistake:
I
set
my
variable,
I
called
it,
and
I
realized
that
Canada
is
not
a
whiskey.
I
I
made
a
typo
I
can
do
two
things.
I
could
recreate
the
array
or
I
could
go
ahead
and
use
the
index
again
in
order
to
fix
my
mistake.
In
this
case,
I'm
saying:
look:
I
need
to
change
index
five
I
happen
to
know
that
the
Canada
one
is
index
five
I'm
going
to
change
that
I'm
going
to
set
it
equal
to
Canadian,
and
then,
when
I
call
my
whiskey's
variable
again
Canadian.
A
B
A
Oh,
that
was
me,
make
your
code
readable,
explicit,
is
so
much
easier
to
read
than
implicit,
so
I
highly
highly
highly
recommend
that
we
stop
using
aliases
in
our
code
that
we
are
going
to
either
have
to
consume
later
or
are
writing
it
for
other
people
to
consume
I
bring
this
up
because
there
is
an
alias
for
it.
Like
I
said,
please
don't
learn
it
that
is
going
to
be
by
the
pipeline.
A
We
have
the
for
each
loop
on
the
for
each
loop
is
something
that
we
will
get
to,
but
it's
a
way
to
loop
through
and
have
something
be
accomplished
on
every
item
in
the
array,
and
then
we
have
the
for
each
method.
Now.
This
is
a
method
that
is
associated
with
the
race
or
the
array
type,
and
we
will
talk
about
that.
We
also
have
the
switch
loop.
The
switch
loop
is
a
great
way
of
going
through
each
item
and
having
something
be
performed,
and
then
we
have
the
for
loop
up
until
today.
A
I
never
seen
any
PowerShell
code
written
with
the
for
loop,
I
thought
today
and
I
was
impressed,
so
it
is
out
there,
but
we're
actually
going
to
go
over
each
of
these
methods,
except
for
the
for
loop.
If
you
are
interested
in
it
or
you
think
you
have
a
need
for
it,
you
know
go
ahead
and
look
it
up,
but
I
think
for
the
majority
I'm
pretty
sure
that
these
four
options
will
cover
what
you
need.
A
So
we'll
talk
about
the
for
each
object
first,
and
this
is
via
the
pipeline
right.
This
is
where
what
PowerShell
allows
us
to
do.
Is
it
allows
us
to
take
our
variable
use
this
character
here?
That
character
will
tell
PowerShell,
hey,
send
this
variable
down
the
pipeline
and
then
what
we're
going
to
do
is
we're
going
to
call
for
each
object,
and
then
we
have
our
open,
curly
braces,
open,
curly
braces
tells
us
to
go
ahead
and
call
this
command
write,
output
and
now
I've
got
my
string.
A
What
I
want
to
write
dollar
sign
PS
item
is
good,
close
curly
bracket.
Everything
inside
that
curly
bracket
is
called
a
script
block
that
will
be
executed.
Okay
on
each
object,
so
when
I
execute
it
I
get
bourbon
is
good,
right
is
good.
Scotch
is
good.
Single
malt
is
good.
Irish
is
good,
Canadians
good
they're,
all
good
and
I
I
was
able
to
do
that
by
the
pipeline.
Sometimes-
and
this
goes
back
to
my
alias
or
actually
let
me
talk
about
dollar
sign
PS
item.
A
This
is
an
automatic
variable
that
gets
created
when
you
are
going
through.
This
PS
item
refers
to
the
one
item
that
I'm
working
with
now,
because
what
arrays,
what
this
for
each
does
is
it
goes
alright.
Let
me
take
the
first
object
and
let
me
do
something
with
it.
Alright.
Now
let
me
take
the
next
object,
so
we
need
a
way
to
refer
to
that.
That
is
this
dollar
sign
PS
item
that
is
automatic.
A
That
is
also
a
way
to
do
this
again.
It's
an
alias
and
I
will
admit
to
you.
My
sin:
I
used
dollar
underside,
underscore
all
the
time
either
way
will
work.
Thank
you.
Thank
you.
Dollar
underscore
will
work.
You
will
see
it
written
this
way
out
in
the
wild,
but
that's
all
it
means
is
dollar
sign,
PS
item
the
for
each
loop,
I
would
say
that
I
use
this
99.9%
of
my
scripts.
I
I,
don't
really
use
the
other
methods.
A
A
A
When
I
run
it
it
does,
the
same
thing
is
that
is
that
for
each
you're
going
to
see
this
version,
in
my
opinion,
is,
is
that
you're
going
to
see
this
version?
When
you
have
a
lot
of
complex
code
here,
this
script
block
can
get
very,
very
complex,
very,
very
quickly.
I've
got
a
script
that
I
wrote
for
a
customer
of
mine
and
I
have
one
for
each
loop.
A
Because
what
works
in
this
block
right
here,
we
are
explicitly
saying,
take
take
the
first
item
out
of
whiskey's
and
put
it
into
this
variable,
whiskey
right
and
then
once
I,
once
we've
completed
that
come
back
up
to
the
top.
Take
the
next
item
out
of
whiskey's
and
put
it
into
whiskey.
When
we
are
looking
at
this,
when
we
are
looking
at
this
item,
we
don't
have
an
opportunity
to
name
our
variable
right,
we're
not.
We
don't
have
a
way
to
say
you
know
like
call
it
call
this
whiskey.
B
A
All
right
for
each
method-
oh
man,
29,
slides
through
28
minutes
in
you
guys
we're
on
a
roll
here,
okay
for
each
method.
So
again,
this
is
a
method.
Remember
when
we
saw
get
type
right,
get
type
am
I
going
the
right
way:
yeah
yeah,
yeah,
yeah
I'm,
going
the
right
way.
Okay,
the
get
type
is
a
method.
Again
we
have
our
variable
dot.
Our
method
and
with
one
of
our
methods
is
for
each.
We
have
the
opportunity
again
to
open
parens,
curly
brace
script
block.
A
Whenever
you
see
a
curly,
brace,
think
script
block
right,
right,
output,
I
did
it
myself.
Dollar
under
sign
is
good,
so
we
get
that
output,
three
different
ways
to
really
achieve
the
same
objective
again.
This
is
going
to
this
could
be
used
in
very,
very
simplistic
code.
Where
you're,
not
you
don't
have
a
lot
of
logic
behind
it.
You
don't
have
a
lot
of
well.
A
A
A
It's
not
like
a
try
except
it's.
The
way
that
I
have
it
is
I've,
got
my
whiskey's
and
then,
when
I
say
switch
on
the
variable.
That
means
go
through
each
item
right
and
match
it
to
bourbon
rye
or
something
else.
Okay,
now
you
can
get
a
lot
more
complex
with
a
switch
statement.
This
talk
is
not
about
the
switch
statement,
so
I'm
not
going
to
get
more
complex.
A
This
is
about
arrays,
but
you
can
use
arrays
in
switch
statements.
So
what
we're
going
to
do
is
without
again
calling
a
specific
variable
it's
going
to
go
through
and
it's
going
to
iterate
through
each
object
in
the
for
each
or
in
the
whiskey's
array,
and
it
is
going
to
match
that
item
based
on
what
I
have
here.
So
if
I
misspelled
bourbon
up
there
nothing's
going
to
happen
because
it
won't
match
right.
A
So
when
I
run
this
I
get
my
output
I
get
you
know
different
outputs
depending
on
the
item
of
the
array,
so
that
is
a
switch
loop.
How
do
I
filter
a
race
because
sometimes
I've
got
two
thousand
items
or
ten
thousand
items.
There
are
a
hundred
thousand
items.
I
only
want
certain
items.
Well,
we've
got
the
where
object
again.
The
pipeline.
The
pipeline
is
important
here
and
then
the
way
or
method
so.
A
Again,
just
like
the
for
each
method,
this
is
a
method
that
is
associated
with
the
Rays
that
we
can
call
and
we'll
look
at
an
example.
So
where
object,
this
is
a
pipeline
again
right
in
this
case,
I
have
ten
numbers
and
I
go
ten
numbers
pipe
it
where
object
dollar
underscore
percent
two
percent
in
PowerShell
means
modular
or
mod
modulo.
Thank
you.
A
modulo
two
meaning
remainder
I'm,
going
to
take
my
number
I'm
going
to
divide
it
by
to
show
me
what
the
remainder
is:
equals
zero.
A
A
B
A
That's
ok,
thank
you.
I
know
who
to
talk
to
if
you
want
candy
so
yeah.
So
in
this
case
we
have
odd
numbers.
So
this
is
just
a
way
for
us
to.
You
know,
apply
some
logic
in
order
to
get
this
now.
There
is
a
whole
bunch
of
logic
that
you
can
apply
in
order
to
get
what
you're
looking
for,
and
it
really
depends
on
your
situation
as
to
you
know,
if
you're
going
to
use
an
equals
or
a
match
or
a
math
function
or
this
or
that
or
the
other
thing
again.
A
A
Yes,
you
can
absolutely,
and
that
is
one
of
the
things
is
because
what
and
this
is
getting
into
the
internals
of
PowerShell,
but
it's
it's
almost
like
a
hidden
pipeline
is
what's
happening
as
it
goes
down
right,
your
dot.
Okay,
send
it
to
this
next
thing:
send
it
to
this
next
thing
and
it
can.
It
can
become
really
ugly
but
really
useful,
not
as
ugly
as
regex,
but
still
pretty
ugly.
So
how
do
I
remove
data
from
erase
you
don't.
A
Date
of
insider
race
can
be
updated,
but
individual
items
cannot
be
removed,
meaning
if
you
want
a
ruse
on
that,
you
can
set
it
to
dollar
sign
null,
meaning
look:
there's
nothing
here
to
see
kind
of
move
on
to
the
next
one,
but
it's
still
taking
up
an
index
space.
It's
still
there
and
then
using
a
logic.
You
can
create
a
new
array,
so
using
logic
you
can
create
a
new
array.
Again
we
talked
about
the
dot
dot,
meaning
for
every
number
in
this
range
inclusive.
A
Put
that
into
my
number
array.
So
again,
I'm
going
to
use
evens.
My
evens
is
going
to
equal
for
each
number
in
number
array.
Script
block.
If
number
is
divisible
by
two
output:
number:
okay,
when
I
say
output
number
here,
you
know
and
we're
going
to
get
into
to
this
a
little
bit
later
so
help
this
work
with
me
here
we're
going
to
shove
it
into
that
variable.
We're
going
to
create
a
new
array
where,
if
I
do
even's
dot
count
is
50
number
a
dot
count
is
a
hundred
meaning.
A
B
A
Inside
of
race
can
be
updated
by
increasing
the
size.
Count
of
the
array
is
not
possible,
less
I
think
you're,
forgetting
about
the
plus
equals
operator,
get
about
it.
If
you've
never
learned
it
don't
learn
it.
If
you
have
I'm
going
to
show
you
why
it's
bad,
what's
wrong
with
a
plus
equals
operator
array
plus
equals
is
expensive.
A
You
might
say
yourself.
My
computer
is
so
fast
doesn't
matter
if
you
say
that
you
obviously
weren't
here
for
the
previous
session,
because
we
found
out
that
it's
all
I/o,
but
it
negatively
impacts
performance.
It
absolutely
negatively
impacts
performance,
and
let
me
tell
you
why
arrays
are
immutable
when
you
do
the
plus
equals
what
you
are
doing
is
you're,
saying
I've
got
this
old
array
and
I
need
to
add
an
item
to
it.
Take
all
the
data
that
was
in
there
create
a
new
item,
shove
all
that
data
into
that
new
item
and
append.
A
My
last
item,
you
do
that
for
one
item.
Okay,
do
that
for
two
items
you
do
that
for
10,000
items,
what's
gonna
happen!
Well,
I
tested
it.
So
if
I
have
values,
one
through
10,000
I
create
my
empty
array
for
each
value
in
values.
My
array
plus
equals
value.
My
array
count
at
the
end
is
10,000.
I've
got
a
really
cool
function
in
my
prompt.
That
shows
me
how
long
the
last
command
took
that
took
five
point,
one
five
seconds
to
run.
Okay,
what
happens
if
you'll
have
a
hundred
thousand
any
guesses
hundred
thousand.
B
A
That
longer,
you
think
10
times
longer
wrong.
Any
other
guesses,
almost
10
minutes
to
run
this
I
might
not
be
stats
101,
but
I
ran
it
a
few
times.
A
A
How
do
I
build
the
dynamically
size
array?
Then
I,
don't
know
how
many
items
are
in
there.
I
need
to
just
be
able
to
do
my
thing,
man
all
right,
well,
cool!
This
is
where
this
comes
in.
My
array
equals
for
each
value
in
values,
output,
value.
What
this
is
going
to
do
is
this
is
going
to
actually
act
like
a
pipeline
and
it's
going
to
do
everything
on
the
right
side
of
the
equal
sign
first
before
it
assigns
it
to
the
left
side.
A
Okay-
and
this
is
a
classic
example
of
where
you're
going
to
want
to
use.
It
is
in
your
for
each
statement
because
you
may
not
know
how
many
items
you
have
to
output,
but
if
you
go
through
your
for
each
statement,
you
apply
logic
to
it
and
then
you
shove
it
into
the
array.
You
can
see
that
I've
added
10,000
items
and
just
spoiler
alert
10,000
items.
I
lost
1,
2
five
seconds
left
23
milliseconds
to
do
10,000
items
in
this
method.
A
So
how
does
that
scale
very
well,
go
to
10,000
items
0.2
seconds
to
do
it
so
and
as
you
go
up
and
up
and
up
this
is
going
to
you
know,
scale
appropriately
right.
It's
almost
in
the
last
one
was
exponential.
Almost
this
is
very,
very
closer
to
linear.
In
fact,
you
know
some
of
these
values
may
change
a
little
bit
just
because
the
measure
command
is
a
little
yeah,
but
you're
going
to
see
better,
better,
better,
better,
better
performance
using
this
method
than
the
plus
equals
method,
all
right
les.
A
What
if
we
need
to
add,
remove
I
can't
live
without
adding
and
removing.
Well,
we
got
two
options.
We
got
the
ArrayList
and
then
we've
got
the
generic
list.
A
regulus
is
deprecated,
so
if
you
don't
know
it
don't
use
it
learn
array
learning
about
your
generic
list.
If
you
do
use
it,
you
can
get
by
it'll
still
work.
It
still
functions,
but
you
know
try
to
start
using
generic
lists.
A
A
A
Is
in
core,
it
is
a
core
yeah.
Generic
lists
is
the
way
to
go
now.
Remember
at
the
beginning,
I
said
strongly:
typed
is
a
well
strongly-typed
is
demanded
in
this
generic
list.
Right
you
actually
have
to
tell
the
list
what
type
of
operation
or
what
type
of
data
is
going
go
in
there.
Let's
say
you
don't
know.
Well,
just
tell
it
it's
the
PS
object,
let
it
figure
it
out
later
right,
but
if
you
can
strongly
type
it
I
recommend
doing
so
again.
So
this
is
just
an
example.
A
In
this
case,
I
declare
my
variable
I,
do
my
count.
I
have
zero
items.
I
go
through
a
few
ads.
I
now
have
three
items
in
there:
I
output,
the
items
and
there
they
are
again
I-
have
all
the
access
to
all
the
other
stuff.
We've
talked
about
using
generic
lists.
I,
don't
need
to
reinvent
the
wheel.
I,
don't
need
to
learn
anything
else.
I
just
need
to
declare
it
in
a
slightly
different
way.
A
B
B
A
Not
removing
zero
I'm
removing
the
item,
because
PowerShell
is
going
to
evaluate
this
understand
what
it
is
and
remove
it
just
like
if
I
were
to
use
text
so
again,
whiskey,
zero,
I'm
asking
for
what
is
in
index
zero.
At
this
point,
it's
rye
whiskies,
remove
rye,
so
I
can
call
it
by
the
item
that
it
actually
is
I,
don't
have
to
know
where
it
is
I
mean
if
it
appears
multiple
times
it's
going
to
find
the
first
one
is
going
to
remove
it.
A
C
C
A
Glad
you
asked
I,
don't
have
a
fancy
graph,
the
the
performance
is
so
much
better
than
plus
equals
it's
slightly
more
expensive,
slightly,
like
I.
Think.
A
hundred
thousand
items
was
like
three
three
hundred
milliseconds
right
rather
than
211
milliseconds,
but
it
is
more
expensive
all
right.
What
did
I
leave
out
because
it
is
1044
and
we
are
almost
through
53,
slides,
crazy
couple.
Things
I
left
out
comparison
operators,
because
this
is
a
whole
nother
kettle
of
fish
right
equals
not
equals
contained
and
in.
A
Learn
about
those
two:
it
will
save
you
so
much
headache,
but
I.
Consider
that
a
102
topic
unfortunately-
and
this
is
101
match
regex,
replace
you
put
and
then
split
I
didn't
cover
those
okay,
Oh
resources.
Where
did
I
learn
this
stuff
right,
get
help
boundaries
better
yet
get
help
about
a
race
online
go
to
the
go.
The
bookmark
the
the
documentation
is
on
Microsoft
Power
Cell
explained
all
about
a
raised
bike
and
I'm
going
to
slaughter
the
Man's
last
name:
Kevin
Marquette.
He
is
PowerShell
genius.
A
A
Arraylist
rather
than
generic
list,
but
the
data
is
still
good,
partial
months
of
lunches
by
Don
John
and
Geoffrey
Hicks
Tyler
line
Leonhardt,
who
is
very
active
in
the
Twitter
community.
He
just
is
republishing
this
for
mac,
OS
and
Linux
with
powershell
core
I
announced
it
yesterday.
I
haven't
bought
it
yet,
but
I'm
planning
on
doing
it,
I
highly,
recommend
it
and
then
partial
cones.
A
We,
if
you
are
learning
powershell
download
this
figure
it
out
it
uses
pester
to
help
to
help
out
what
you
you
know
to
help
before
I
move
on.
We
are
going
to
stop
that
we're
going
to
help
hope
that
this
works,
because
you
know
can
I
send
this
hey.
It
works.
Ok,
so
I
want
to
talk
about
the
pipeline,
real,
quick
and
something
to
be
aware
of
oops.
A
So
I've
got
my
array
I've
just
set
it
to
one
two.
Three
four
I
wasn't
going
to
do
this
demo
until
about
an
hour
ago
and
then
I
realized
that
I
need
to
it
be
careful
of
the
pipeline
right.
So
what
I
can
say
there
is
a
there's.
A
process
in
PowerShell
called
get
member
get
member
is
going
to
show
you
everything
you
need
to
know
about
the
object,
but
I've
got
integers
here
numbers.
A
So,
if
I
do
my
array
get
member
which
is
perfectly
valid
and
legal,
it's
going
to
send
it
to
the
pipeline
and,
what's
going
to
happen,
is,
is
I'm
going
to
get
it
name
of
integer
32?
These
are
methods
and
of
parameter
or
methods
and
properties
for
the
integer
type,
not
for
the
array
type
you
might
get
tripped
up
if
you're,
like
oh
man,
I
can't
remember
what
that
was.
How
do
I
do
it?
What
we
need
to
do
is
we
need
to
go
get
member.