►
From YouTube: PnP Shorts - Authentication and PnP PowerShell
Description
Learn about the various approaches with PnP PowerShell to ease authentication to your site and how to use secure authentication when using PnP PowerShell to create scheduled tasks.
See for all connection options (credentials, multi-factor auth, app-only, graph, etc.) https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/connect-pnponline
A
So
this
works
fine,
but
it
becomes
a
bit
tedious.
If
you
want
to
repeat
this
another
issue
you
have
with
this
is:
if
you
build
your
own
scripts,
that
you
want
to
use
an
automation
like,
for
instance,
running
scheduled
tasks,
every
five
minutes
or
every
hour
you
cannot
handle
and
pop
up
from
there
because
yeah
you're
automating
it.
You
run.
That's
it's
somewhere
in
the
background,
so
a
possible
scenario.
There
would
be
this.
Take.
You
include
two
username
and
a
password
to
your
script,
but
obviously
that's
not
the
most
secure
solution.
A
Someone
gets
all
of
the
scripts
and
you
have
you
shared
your
passwords.
So
the
approach
there
is
is
relatively
simple,
but
it
requires
a
theorem
on
obviously
on
a
Windows
machine
but
yeah
the
powershell
commandlets
only
work
on
Windows
currently
so
solution
is
there
to
use
the
windows
credential
manager.
So
if
you
launch
the
credential
manager
in
Windows,
it's
located
in
the
control
panel,
but
if
you're
on
Windows
10
the
easiest
way
to
do
it
is
just
loading
the
Start
menu
and
type
credential
manager.
A
Here's
the
credential
manager.
Now
what
you
do
here
is
you
create
a
credential
for
that?
You
want
to
use
with
the
pin
P
commandlets,
so
you
switch
to
Windows
credentials
and
then
you
say
add
the
generic
credential.
Now
there's
two
approaches
you
can
follow
here
you
can
just
enter
a
label
and
I'll
do
that
first
and
then
I'll
show
you
another
way
that
this
may
be
easier,
but
for
now
I'll
just
create
a
label
and
say
Aaron
MCM,
which
the
name
of
my
tenants.
A
A
Share
and
then
I
specify
credentials
and
then
I
say
every
MCM.
What
the
powershell
commandlets
will
do
now
is
that
it
will
connect
to
the
credential
manager,
retrieve
those
credentials
and
use
those.
The
information
is
found
in
the
credential
manager
to
connect
to
the
site.
If
I
press
enter
see,
there's
no
prompt,
I'm
just
automatically
connected
and
all
the
commands,
let's
work.
A
So
this
works
by
means
of
specifying
this
label
like
here
and
maybe
easier
way
to
do.
It
is
by
not
specifying
the
label,
but
if
you
go
back
the
credential
manager
and
I
say
at
a
generic
national
and
then
I
just
enter
an
Internet
address
here.
So
I
enter
the
address
of
my
tenants
and
then
again
the
username
and
the
password.
A
You
can
play
a
bit
with
this
address,
so
if
I,
just
if
I
want
to
say
ok,
you
should
only
use
these
credentials
for
the
site
called
test.
Then
this
will
apply,
but
you
can
actually
say:
ok,
so
every
site
collection
under
decides
path.
I
want
to
use
these
credentials,
so
you
can
play
it
with
disabilities.
Url
here
effectively
kind
of
a
wild-card
you
can
create
here,
but
right
now,
I'm.
Sorry,
you
want
to
use
this
credential
for
every
site.
Within
my
tenant,
I
just
entered
the
the
hostname
of
my
tenant
click.
A
Ok
I
can
close
the
credential
manager
here.
If
I
now
connect
to
my
site,
Connect
PNP
online
and
I
say
share
points.
Let's
come
I,
don't
have
to
specify
the
credentials
parameter.
It
will
just
automatically
connect
again
to
the
credential
manager
figure
out.
What
my
username
and
password
is.
Am
I
authenticated?
A
The
only
thing
you
have
to
do
right
now
is
that
if
you
change
your
password,
you
obviously
will
have
to
update
the
entry
individual
windows,
credential
manager.
The
thing
to
remember
is
that
if
you
use
this
approach
to
automate
or
create
automation,
scripts
like
at
scheduled
tasks,
then
those
tasks
usually
run
under
a
different
identity.
A
It's
important
to
understand
that
you
have
to
use
the
credential
manager
for
that
specific
identity
that
user,
so
you
have
to
log
in
with
that
user,
account
on
the
machine
and
then
go
to
the
credential
manager
and
create
the
credentials
there.
So
it's
not
enough
that
you
created
because
every
user
has
a
history
on
credential
manager,
so
in
Windows,
so
this
is
a
simple
way
of
automating
your
scripts.
Another
thing
I
would
like
to
explain
is
how
to
connect
with
the
powershell
commandlets.
A
If
you
use
two-factor
authentication
in
order
to
do
that,
you
will
have
to
use
a
different
way
of
authenticating,
and
that
is
that
you
specify
use
web
login.
What
will
happen
now
if
I
press
enter?
Instead,
there
will
be
a
dialog
pop-up,
and
you
see
that
over
the
authenticated,
and
why
am
I
authenticated
right
now?
A
So
if
you
do
this
the
first
time,
you
will
see
a
dialog
pop
up
and
it
will
ask
you
to
enter
your
username
and
a
password
and
then
you
will
be
challenged
for
the
two
effects
for
the
second
factor,
so
you
will
receive
an
SMS
on
your
phone
or
whatever
takes
technique.
You
use,
and
you
confirm
that
and
then
it
will
ask
you
if
you
want
to
stay,
authenticated
locked
in
sorry,
and
if
you
say
yes
under
the
answer,
it
remembers
that
so
it's
not
the
powershell
commandlets.
They
don't
remember
that.
A
It's
actually
done
by
means
of
a
cookie,
so
now
you're
authenticated
automatically,
and
this
effect
is
the
same.
It's
a
bit
more
complex
to
set
this
up.
If
you
want
to
do
this
ultimate
is
obviously
so
for
the
automation
approach,
where
you
want
to
schedule
scripts
at
certain
intervals,
I
would
recommend
you
to
use
the
windows
credential
manager.
That
is
the
easiest
way
forward.