Professional Documents
Culture Documents
Azure Powershell
Azure Powershell
Course Navigation
I n t r odu ct ion t o
Pow er Sh ell
Section 2
M an agin g Azu r e w it h
Pow er Sh ell
Section 3
Next
Back t o M ain
Course Introduction
Course Navigation Cou r se I n t r odu ct ion
I n t r odu ct ion t o Welcom e to the Linux Academ y Azu r e Pow er Sh ell Essen t ials
Pow er Sh ell course.
Section 2
In this course, we set the foundation to begin learning PowerShell,
specifically with Microsoft Azure. We will start by discussing the
M an agin g Azu r e w it h basics of PowerShell, including com m ands and syntax. Next, we'll
Pow er Sh ell m ove into creating and m anaging Azure resources, subscriptions,
Section 3 and identities with PowerShell. Finally, we'll put everything together
and start building our own scripts.
Scr ipt in g f or Azu r e This is a beginner-level course. The only prerequisites are a basic
Section 4 knowledge of networking, client-server com m unications, and som e
decent troubleshooting skills.
Learning Azure PowerShell will help autom ate our adm inistrative
tasks, gather useful inform ation from our resources, and take that
next step in career advancem ent.
Cor ey Kn app
Next
Back t o M ain
Course Introduction
Course Navigation Abou t t h e Tr ain in g Ar ch it ect
I n t r odu ct ion t o
Pow er Sh ell
Section 2 Per son al Lif e: Born in California, raised in New Jersey, but now
living in Chapel Hill, North Carolina, Corey Knapp has been all over
the United States. He loves the winter but hates the cold, and loves
M an agin g Azu r e w it h the sum m er but hates the heat. Even in his own m ind, Corey is an
Pow er Sh ell enigm a. In his free tim e, he loves spending tim e with his teenage
Section 3 children, Anna and Logan, and his wife of 18 years, Michele. Corey
has a passion for learning and is ready to spread that eagerness to
others.
Scr ipt in g f or Azu r e
Section 4
Back t o M ain
Introduction to PowerShell
Course Navigation Pow er Sh ell Basics
I n t r odu ct ion t o
Pow er Sh ell
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics Select on the item s below to learn m ore
What is PowerShell?
about the PowerShell basics:
Installing PowerShell
PowerShell Versus
PowerShell Core
M an agin g Azu r e w it h
Pow er Sh ell
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Wh at is Pow er Sh ell?
I n t r odu ct ion t o
Pow er Sh ell
Section 2
Over view
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell?
A
Wh at I s Pow er Sh ell an d Wh at Can
Installing PowerShell
PowerShell Versus
We Do Wit h I t ?
PowerShell Core
Benefits of Learning
PowerShell PowerShell is built on the .NET fram ework
Basic Com m ands in and is both a scripting language and an
PowerShell interactive com m and environm ent.
PowerShell Modules
Pow er Sh ell Con cept s PowerShell allows for easier adm inistration
Com m and and Syntax of system s and the autom ation of repetitive
Basics tasks.
The Three Most Im portant
Com m ands in PowerShell
Using Variables
A Wh at Can Pow er Sh ell M an age?
Understanding PowerShell
Pipelines
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation I n st allin g Pow er Sh ell
I n t r odu ct ion t o
Pow er Sh ell
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell?
IInstalling
n st allin gPowerShell
Pow er Sh ell
PowerShell Versus
PowerShell Core
Benefits of Learning
PowerShell
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation I n st allin g Pow er Sh ell
I n t r odu ct ion t o
Pow er Sh ell
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell?
IInstalling
n st allin gPowerShell
Pow er Sh ell
PowerShell Versus
PowerShell Core
Benefits of Learning
PowerShell
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Pow er Sh ell Ver su s Pow er Sh ell Cor e
I n t r odu ct ion t o
Pow er Sh ell Sh ou ld We Use Pow er Sh ell or
Section 2 Pow er Sh ell Cor e?
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell?
1
IInstalling
n st allin gPowerShell
Pow er Sh ell
PowerShell Modules 2
Pow er Sh ell Con cept s
Pow er Sh ell Cor e - PSC 6.1 is the latest release.
Com m and and Syntax
Basics
- Unsupported m odules.
The Three Most Im portant
- Open source (MacOS, Linux).
Com m ands in PowerShell
Using Variables
Understanding PowerShell 3
Pipelines
Pow er Sh ell in Azu r e Th e Bot t om Lin e - PSC is the next evolution of PS.
Installing the Azure - Version 7.0 will replace both.
PowerShell Module - True cross-platform support.
Signing into Azure - PS for now, PSC in near future.
The Most Im portant Azure
PowerShell Com m ands
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Ben ef it s of Lear n in g Pow er Sh ell
I n t r odu ct ion t o
Pow er Sh ell Wh y Sh ou ld We Use Pow er Sh ell?
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell? PowerShell is a powerful scripting tool that can expedite our
IInstalling
n st allin gPowerShell
Pow er Sh ell
adm in tasks and increase our daily productivity. Here are som e
of the ways we can benefit from PowerShell.
Pow er Sh ell Versus
PowerShell Ver su s
Pow er Sh ell Core
PowerShell Cor e
Ben ef it sof
Benefits of Learning
Lear n in g
Pow er Sh ell
PowerShell
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Basic Com m an ds in Pow er Sh ell
I n t r odu ct ion t o
Pow er Sh ell Basic Pow er Sh ell Com m an ds
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell? There are a few com m ands every PowerShell user should know.
IInstalling
n st allin gPowerShell
Pow er Sh ell These com m ands help m ake everyday tasks easier and are
Pow er Sh ell Versus
PowerShell Ver su s som e of the key building blocks in learning PowerShell.
Pow er Sh ell Core
PowerShell Cor e
Ben ef it sof
Benefits of Learning
Lear n in g
Pow er Sh ell
PowerShell
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell
PowerShell Modules
St ar t - Pr ocess Get - Hel p Get - Command
Pow er Sh ell Con cept s
Com m and and Syntax
Basics
The Three Most Im portant
Com m ands in PowerShell
Using Variables St ar t - Ser vi ce
Understanding PowerShell and
Pipelines Get - I t em Get - Cont ent
St op- Ser vi ce
Pow er Sh ell in Azu r e
Installing the Azure
PowerShell Module
Signing into Azure
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Pow er Sh ell M odu les
I n t r odu ct ion t o
Pow er Sh ell
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
is PowerShell?
Pow er Sh ell? A
What
Wh at I s a Pow er Sh ell M odu le?
IInstalling
n st allin gPowerShell
Pow er Sh ell
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Pow er Sh ell Con cept s
I n t r odu ct ion t o
Pow er Sh ell
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell?
IInstalling
n st allin gPowerShell
Pow er Sh ell Select on the item s below to learn m ore
Pow er Sh ell Versus
PowerShell
Pow
Ver su s
er Sh ell Core
PowerShell Cor e
about the PowerShell concepts:
Ben ef it sof
Benefits of Learning
Lear n in g
Pow er Sh ell
PowerShell
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell
Com m an d an d Syn t ax Basics
PowerShell
Pow er Sh ell Modules
M odu les
M an agin g Azu r e w it h
Pow er Sh ell
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Com m an d an d Syn t ax Basics
I n t r odu ct ion t o
Pow er Sh ell A Syn t ax Basics
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell?
IInstalling
n st allin gPowerShell
Pow er Sh ell
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell
PowerShell
Pow er Sh ell Modules
M odu les All PowerShell cm dlets follow a sim ple
Pow er Sh ell Con cept s verb-noun syntax.
Com m
Com m and
an d and
an d Syntax
Syn t ax
Basics
Basics
The Three Most Im portant Do som ething - To som ething
Com m ands in PowerShell
Using Variables
Understanding PowerShell PowerShell cm dlet:
Pipelines Get - Hel p
Pow er Sh ell in Azu r e
Installing the Azure
PowerShell cm dlet with param eter:
PowerShell Module
Get - Hel p - name " * net wor k * "
Signing into Azure
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Th e Th r ee M ost I m por t an t Com m an ds in Pow er Sh ell
I n t r odu ct ion t o
Pow er Sh ell
Section 2
I m por t an t Com m an ds in Pow er Sh ell
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell? Get - Hel p
IInstalling
n st allin gPowerShell
Pow er Sh ell A Use this cm dlet to get inform ation on how to
Pow er Sh ell Versus
PowerShell Ver su s use a cm dlet. Also type hel p or man.
Pow er Sh ell Core
PowerShell Cor e
Ben ef it sof
Benefits of Learning
Lear n in g
Pow er Sh ell
PowerShell
Get - Command
Basic Com
Comm mands
an dsinin Use this cm dlet to get only the com m ands
Pow er Sh ell
PowerShell
B
im ported into PowerShell.
PowerShell
Pow er Sh ell Modules
M odu les
Pow er Sh ell in Azu r e These three com m ands are the building blocks of learning to
use PowerShell on a daily basis. Adm ins can use these three
Installing the Azure
PowerShell Module com m ands to get inform ation on all other com m ands in
Signing into Azure PowerShell, list which com m ands are available, and gather
The Most Im portant Azure basic inform ation on services currently running in their
PowerShell Com m ands environm ent.
Working with Outputs
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Usin g Var iables
I n t r odu ct ion t o
Pow er Sh ell
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell?
IInstalling
n st allin gPowerShell
Pow er Sh ell
Ben ef it sof
Benefits of Learning
Lear n in g
Pow er Sh ell
PowerShell
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell
PowerShell
Pow er Sh ell Modules
M odu les PowerShell works with objects and lets us create
nam ed objects known as variables.
Pow er Sh ell Con cept s
Com m
Com m and
an d and
an d Syntax
Syn t ax
Basics
Basics Variable nam es can include the underscore
The
Th e Three
Th r ee Most
M ost Im
I mportant
por t an t character and any alphanum eric character. We
Com m
Com m ands
an ds in
in PowerShell
Pow er Sh ell specify variables using the $ character followed by
Usingg Variables
Usin Var iables the variable nam e.
Understanding PowerShell
Pipelines
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Un der st an din g Pow er Sh ell Pipelin es
I n t r odu ct ion t o
Pow er Sh ell Wh y Use Pipelin es?
Section 2
Pow er
erSh
Shell
ell Basics
Basics
A pipeline is a series of com m ands connected by pipeline
Pow
operators (| ). Each operator sends the results of the preceding
Wh at is
What is PowerShell?
Pow er Sh ell?
com m and to the next com m and.
IInstalling
n st allin gPowerShell
Pow er Sh ell
Ben ef it sof
Benefits of Learning
Lear n in g In this exam ple, objects from Com m and-1 are sent to
Pow er Sh ell
PowerShell
Com m and-2. Com m and-2 then processes the objects
Basic Com
Comm mands
an dsinin and sends them to Com m and-3.
Pow er Sh ell
PowerShell
PowerShell
Pow er Sh ell Modules
M odu les
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Un der st an din g Pow er Sh ell Pipelin es
I n t r odu ct ion t o
Pow er Sh ell Wh y Use Pipelin es?
Section 2
Pow er
erSh
Shell
ell Basics
Basics
A pipeline is a series of com m ands connected by pipeline
Pow
operators (| ). Each operator sends the results of the preceding
Wh at is
What is PowerShell?
Pow er Sh ell?
com m and to the next com m and.
IInstalling
n st allin gPowerShell
Pow er Sh ell
Ben ef it sof
Benefits of Learning
Lear n in g In this exam ple, objects from Com m and-1 are sent to
Pow er Sh ell
PowerShell
Com m and-2. Com m and-2 then processes the objects
Basic Com
Comm mands
an dsinin and sends them to Com m and-3.
Pow er Sh ell
PowerShell
PowerShell
Pow er Sh ell Modules
M odu les
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Pow er Sh ell in Azu r e
I n t r odu ct ion t o
Pow er Sh ell
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics Select on the item s below to learn m ore
Wh at is
is PowerShell?
Pow er Sh ell?
What
about the PowerShell in Azure:
IInstalling
n st allin gPowerShell
Pow er Sh ell
Ben ef it sof
Benefits of Learning
Lear n in g I n st allin g t h e Azu r e Pow er Sh ell M odu le
Pow er Sh ell
PowerShell
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell
Sign in g in t o Azu r e
PowerShell
Pow er Sh ell Modules
M odu les
M an agin g Azu r e w it h
Pow er Sh ell
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation I n st allin g t h e Azu r e Pow er Sh ell M odu le
I n t r odu ct ion t o
Pow er Sh ell Pr er equ isit es
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
is PowerShell?
Pow er Sh ell?
1. Updat e t o Pow er Sh ell 5.1, if n eeded.
What
2. I n st all .NET Fr am ew or k 4.7.2 or lat er.
IInstalling
n st allin gPowerShell
Pow er Sh ell
Ben ef it sof
Benefits of Learning
Lear n in g
Pow er Sh ell
PowerShell I n st allin g t h e M odu le
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell
PowerShell
Pow er Sh ell Modules
M odu les
Working with Outputs Azu r e Pow er Sh ell f or Win dow s is in st alled u sin g
Using Nested Properties t h e M SI f ile available f r om Git Hu b.
Filtering Results
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Sign in g in t o Azu r e
I n t r odu ct ion t o
Pow er Sh ell Con n ect in g t o Azu r e
Section 2
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell?
A
IInstalling
n st allin gPowerShell
Pow er Sh ell
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell
PowerShell
Pow er Sh ell Modules
M odu les B
Pow er Sh ell Con cept s Au t h en t icat e En t er cr eden t ials
Com m
Com m and
an d and
an d Syntax
Syn t ax
Basics
The system prom pts us to sign in
Basics
interactively using a browser.
The
Th e Three
Th r ee Most
M ost Im
I mportant
por t an t
Com m
Com m ands
an ds in
in PowerShell
Pow er Sh ell
Usingg Variables
Usin Var iables
Understanding
Un der st an din gPowerShell
Pow er Sh ell C
Pipelines
Pipelin es
Pow er Sh ell in Azu r e Au t h or ize Per m ission s ar e r equ ir ed
IInstalling
n st allin gthe
t h eAzure
Azu r e
The credentials we use m ust
PowerShell
Pow er Sh ell Module
M odu le have perm issions granted for the
Signing
Sign in g into
in t oAzure
Azu r e resource group and resources.
The Most Im portant Azure
PowerShell Com m ands
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Th e M ost I m por t an t Azu r e Pow er Sh ell Com m an ds
I n t r odu ct ion t o
Pow er Sh ell
Section 2 Usef u l Azu r e Pow er Sh ell Com m an ds
Pow er
Pow erSh
Shell
ell Basics
Basics
Wh at is
What is PowerShell?
Pow er Sh ell?
These com m ands provide a starting point for key PowerShell
IInstalling
n st allin gPowerShell
Pow er Sh ell
com m ands necessary for Azure adm inistrators. It is not all
Pow er Sh ell Versus
PowerShell Ver su s
Pow er Sh ell Core
PowerShell Cor e encom passing, but is a great jum ping-off point.
Ben ef it sof
Benefits of Learning
Lear n in g
Pow er Sh ell
PowerShell
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell
PowerShell
Pow er Sh ell Modules
M odu les St ar t - AzVM
Get - AzVM
Pow er Sh ell Con cept s
Get - AzSubscr i pt i on St op- AzVM
New- AzVM
Remove- AzVM
Com m
Com m and
an d and
an d Syntax
Syn t ax
Basics
Basics
The
Th e Three
Th r ee Most
M ost Im
I mportant
por t an t
Com m
Com m ands
an ds in
in PowerShell
Pow er Sh ell
Usingg Variables
Usin Var iables
Get - AzSt or age
Understanding
Un der st an din gPowerShell
Pow er Sh ell Get - AzResour ceGr oup
Get - AzResour ce Account
Pipelines
Pipelin es New- AzResour ceGr oup
Move- AzResour ce New- AzSt or age
Pow er Sh ell in Azu r e Set - AzResour ceGr oup
Account
IInstalling
n st allin gthe
t h eAzure
Azu r e
PowerShell
Pow er Sh ell Module
M odu le
Signing
Sign in g into
in t oAzure
Azu r e
Th
Thee Most
M ost Im
I mportant
por t an tAzure
Azu r e
Pow er Sh ell Com
PowerShell Commmands
an ds New- AzVi r t ual
Logi n- AzAccount Get - AZVi r t ual Net wor k Net wor k
Working with Outputs
Logout - AzAccount Get - AzLoadBal ancer New- AzPubl i cI P
Using Nested Properties Addr ess
Filtering Results
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Wor k in g w it h Ou t pu t s
I n t r odu ct ion t o
Pow er Sh ell By default, each Azure PowerShell cm dlet form ats output to
Section 2
be easy t o r ead. PowerShell allows you to con ver t or
Pow er
Pow erSh
Shell
ell Basics
Basics f or m at cm dlet ou t pu t by piping to one of the following
Wh at is
What is PowerShell?
Pow er Sh ell? cm dlets:
IInstalling
n st allin gPowerShell
Pow er Sh ell
PowerShell
Pow er Sh ell Modules
M odu les For mat - Li st
Pow er Sh ell Con cept s B Displays two colum ns: one for property
Com m
Com m and
an d and
an d Syntax
Syn t ax nam es and one for property values.
Basics
Basics
The
Th e Three
Th r ee Most
M ost Im
I mportant
por t an t
Com m
Com m ands
an ds in
in PowerShell
Pow er Sh ell
For mat - Wi de
Usingg Variables
Usin Var iables
C Displays one property nam e per query.
Understanding
Un der st an din gPowerShell
Pow er Sh ell
Pipelines
Pipelin es
Displayed property controlled by argum ent.
Pow er Sh ell in Azu r e
IInstalling
n st allin gthe
t h eAzure
Azu r e
PowerShell
Pow er Sh ell Module
M odu le
Signing
Sign in g into
in t oAzure
Azu r e
The Conver t To- * fam ily of cm dlets allows for converting
Th
Thee Most
M ost Im
I mportant
por t an tAzure
Azu r e
Pow er Sh ell Com
PowerShell Commmands
an ds results of Azure PowerShell cm dlets to m ach in e-r eadable
Wor k in g with
w it hOutputs
Ou t pu t s
f or m at s, including CSV, JSON, XML, and HTML form ats.
Working
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Usin g Nest ed Pr oper t ies
I n t r odu ct ion t o
Pow er Sh ell In PowerShell, object pr oper t ies tell us about the object.
Section 2
Each tim e a Get - com m and is run, you receive a single
Pow er
Pow erSh
Shell
ell Basics
Basics object or set of objects. Properties are at t r ibu t es abou t
Wh at is
What is PowerShell?
Pow er Sh ell? t h e object s t h em selves.
IInstalling
n st allin gPowerShell
Pow er Sh ell
PowerShell
Pow er Sh ell Modules
M odu les
Usin g Get - Member
Pow er Sh ell Con cept s B The Get - Member cm dlet shows us a
Com m
Com m and
an d and
an d Syntax
Syn t ax PowerShell object 's defined properties.
Basics
Basics
The
Th e Three
Th r ee Most
M ost Im
I mportant
por t an t
Com m
Com m ands
an ds in
in PowerShell
Pow er Sh ell
Usingg Variables - Pr oper t y f or t h e w in !
Usin Var iables
Understanding C Using the - Pr oper t y param eter with a
Un der st an din gPowerShell
Pow er Sh ell
Pipelines
Pipelin es wildcard value displays all of the properties.
Pow er Sh ell in Azu r e
IInstalling
n st allin gthe
t h eAzure
Azu r e
PowerShell
Pow er Sh ell Module
M odu le
Get - Member and Microsoft docum entation m ay give you an
Signing
Sign in g into
in t oAzure
Azu r e
idea of what properties are helpful to you, but in t er r ogat in g a
Th
Thee Most
M ost Im
I mportant
por t an tAzure
Azu r e
Pow er Sh ell Com
Commmands
an ds
sam ple object dir ect ly using - Pr oper t y * will help you
PowerShell
validate that a property has the in f or m at ion you n eed.
Wor k in g with
Working w it hOutputs
Ou t pu t s
Usin
Usingg Nested
Nest edProperties
Pr oper t ies
Filtering Results
M an agin g Azu r e w it h
Pow er Sh ell Back Next
Section 3
Back t o M ain
Introduction to PowerShell
Course Navigation Filt er in g Resu lt s
I n t r odu ct ion t o
Pow er Sh ell One of the best things about using an object -based
Section 2
pipelin e is that you can f ilt er object s out of the pipeline at
Pow er
Pow erSh
Shell
ell Basics
Basics an y st age. How?
Wh at is
What is PowerShell?
Pow er Sh ell?
IInstalling
n st allin gPowerShell
Pow er Sh ell
PowerShell
Pow er Sh ell Modules
M odu les
Usin g t h e $_ oper at or
Pow er Sh ell Con cept s B $_ represents the current pipeline object. From
Com m
Com m and
an d and
an d Syntax
Syn t ax here, you can choose the property you want to filter
Basics
Basics on.
The
Th e Three
Th r ee Most
M ost Im
I mportant
por t an t
Com m
Com m ands
an ds in
in PowerShell
Pow er Sh ell
Usingg Variables Com par ison oper at or s
Usin Var iables
C Using these operators in conjunction with $_, you
Understanding
Un der st an din gPowerShell
Pow er Sh ell
Pipelines can narrow your list down even further.
Pipelin es
Pow er Sh ell in Azu r e
IInstalling
n st allin gthe
t h eAzure
Azu r e
PowerShell
Pow er Sh ell Module
M odu le
Get - Ser v i c e | Wher e- Obj ect { $_. St at us - eq
Signing
Sign in g into
in t oAzure
Azu r e
" Runni ng" }
Th
Thee Most
M ost Im
I mportant
por t an tAzure
Azu r e
Pow er Sh ell Com
PowerShell Commmands
an ds
In this exam ple, we are searching the St at us property of the Ser v i c e
Wor k in g with
Working w it hOutputs
Ou t pu t s list and filtering to see if the St at us property is equal to Runni ng.
Usin
Usingg Nested
Nest edProperties
Pr oper t ies
Filtering
Filt er in gResults
Resu lt s
M an agin g Azu r e w it h
Pow er Sh ell Back
Section 3
Back t o M ain
Managing Azure with PowerShell
Course Navigation M an agin g Azu r e Resou r ces w it h Pow er Sh ell
I n t r odu ct ion t o
Pow er Sh ell
Section 2 Select on the item s below to learn m ore
about m anaging Azure resources with
M an agin g Azu r e w it h
Pow er Sh ell PowerShell:
Section 3
Man
M anagin
agingg Azu
Azurree Cr eat in g Vir t u al M ach in es u sin g Pow er Sh ell in
Resourrces
Resou ces w
w itit hh
Azu r e
Pow er
Pow erSh
Shell
ell
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g Vir t u al M ach in es u sin g Pow er Sh ell in Azu r e
M an agin g Azu r e w it h
Cr eat e a Vir t u al Azu r e Pow er Sh ell com m an d:
Pow er Sh ell New- Az VM - Res ouc eGr oupName
M ach in e
Section 3 " my Res our c eGr oup" - Name " my VM
- Vi r t ual Net wor k Name " my Vnet "
Man
M anagin
agingg Azu
Azurree
- Subnet Name " my Subnet "
Resourrces
Resou ces w
w itit hh
- Sec ur i t y Gr oupName
Pow er
Pow erSh
Shell
ell
" my Sec ur i t y Gr oup"
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es - Publ i c I pAddr es s Name
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e " my Publ i c I pAddr es s "
- OpenPor t s 80, 3389
Creating Storage Accounts in
Azure
Creating Azure SQL
Databases
Azu r e Pow er Sh ell com m an d:
Creating Standard Load Con n ect t o VM
Get - Az Publ i c I pAddr es s
Balancers in Azure
- Res our c eGr oupName
M an agin g Azu r e I den t it ies " my Res our c eGr oup" | Sel ec t
w it h Pow er Sh ell " I pAddr es s "
Managing Azure
Subscriptions
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g St or age Accou n t s in Azu r e
M an agin g Azu r e w it h
Con n ect t o Azu r e Azu r e Pow er Sh ell com m an d:
Pow er Sh ell Connec t - Az Ac c ount
Section 3
Man
M anagin
agingg Azu
Azurree
Resourrces
Resou ces w
w itit hh
Pow er
Pow erSh
Shell
ell Azu r e Pow er Sh ell com m an d:
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es Set t h e Var iables $r es our c eGr oup = " t es t s t or age"
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e New- Az Res our c eGr oup - Name
$r es r ouc eGr oup - Loc at i on
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin
Azu re
eas t us
Azure
Creating Azure SQL
Databases
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g Azu r e SQL Dat abases
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g St an dar d Load Balan cer s in Azu r e
Man
M anagin
agingg Azu
Azurree $publ i c I p = New- Az Publ i c I pAddr es s `
Resourrces
Resou ces w
w itit hh - Res our c eGr oupName $r gName `
Pow er
Pow erSh
Shell
ell
- Name ' my Publ i c I P' `
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es - Loc at i on $l oc at i on `
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e - Al l oc at i onMet hod s t at i c `
- SKU St andar d
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin
Azu re
Azure
# Cr eat e t he Fr ont - End I P
Creating
Cr eat in g Azure
Azu r eSQL
SQL
Databases
Dat abases
$f ei p = New- Az LoadBal anc er Fr ont endI pConf i g - Name
Creating
Cr eat in g Standard
St an dar dLoad
Load ' my Fr ont EndPool ' - Publ i c I pAddr es s $publ i c I p
Balancers
Balan cer s in
in Azure
Azu r e
M an agin g Azu r e I den t it ies # Conf i gur e t he Bac k - End Addr es s Pool
w it h Pow er Sh ell
$bepool = New- Az LoadBal anc er Bac k endAddr es s Pool Conf i g
Managing Azure - Name ' my Bac k EndPool '
Subscriptions
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g Azu r e SQL Dat abases
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g St an dar d Load Balan cer s in Azu r e
Man
M anagin
agingg Azu
Azurree #$publ
Cr eat i c eI pt he NAT Az
= New- Rul es i c I pAddr es s `
Publ
Resourrces
Resou ces w
w itit hh - Res our c eGr oupName $r gName `
Pow er
Pow erSh
Shell
ell $nat r ul
- Nam e e1 ' my = New-
Publ i c Az
I P'LoadBal
` anc er I nboundNat Rul eConf i g `
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es - -Loc
Nam ate i 'on
my LoadBal
$l oc at i anc
on er ` RDP1' `
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e - -AlFrl ont
oc atendI pConf
i onM et hod i gur
s t at i on
c ` $f ei p `
- -SKU
Pr otStocandar
ol t cdp - Fr ont endPor t 4221 `
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin
- Bac k endPor t 3389
Azu re
Azure
$nat
# Cr reat ul e2e t= heNew- Az LoadBal
Fr ont - End I Panc er I nboundNat Rul eConf i g `
Creating
Cr eat in g Azure
Azu r eSQL
SQL - Name ' my LoadBal anc er RDP2' `
Databases
Dat abases
$f -eiFrpont = endI
New- pConf i gur at
Az LoadBal anci on
er Fr$font
ei pendI
` pConf i g - Name
Creating
Cr eat in g Standard
St an dar dLoad
Load ' m-y Pr
Fr ot
ontocEndPool
ol t c p ' ` - Publ i c I pAddr es s $publ i c I p
Balancers
Balan cer s in
in Azure
Azu r e - Fr ont endPor t 4222 `
M an agin g Azu r e I den t it ies # -Conf
Bac ki endPor
gur e t the3389Bac k - End Addr es s Pool
w it h Pow er Sh ell $nat r ul e3 = New- Az LoadBal anc er I nboundNat Rul eConf i g `
- Name '=myNew-
$bepool LoadBal anc er RDP3'
Az LoadBal anc er Bac` k endAddr es s Pool Conf i g
Managing Azure - Freont
- Nam ' mendI
y Bac pConf
k EndPooli gur' at i on $f ei p `
Subscriptions
- Pr ot oc ol t c p `
Creating Service Principals # -CrFreat onteendPor
a Healt t 4223
h Pr obe `
- Bac k endPor t 3389
Creating Users and Groups in
Azure $pr obe = New- Az LoadBal anc er Pr obeConf i g `
- Name ' my Heal t hPr obe' `
Rem ote Adm inistration - Pr ot oc ol Ht t p - Por t 80 `
- Reques t Pat h / - I nt er v al I nSec onds 360 - Pr obeCount 5
Scr ipt in g f or Azu r e
Section 4
Next
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g Azu r e SQL Dat abases
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g St an dar d Load Balan cer s in Azu r e
M an agin g Azu r e I den t it ies # Conf i gur e t he Bac k - End Addr es s Pool
w it h Pow er Sh ell
$bepool = New- Az LoadBal anc er Bac k endAddr es s Pool Conf i g
Managing Azure - Name ' my Bac k EndPool '
Subscriptions
Back t o M ain
Managing Azure with PowerShell
Course Navigation M an agin g Azu r e I den t it ies w it h Pow er Sh ell
I n t r odu ct ion t o
Pow er Sh ell
Section 2 Select on the item s below to learn m ore
about m anaging Azure identities with
M an agin g Azu r e w it h
Pow er Sh ell PowerShell:
Section 3
Man
M anagin
agingg Azu
Azurree
Resourrces
Resou ces w
w itit hh M an agin g Azu r e Su bscr ipt ion s
Pow er
Pow erSh
Shell
ell
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e Cr eat in g Ser vice Pr in cipals
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin
Azu re
Azure
Creating
Cr eat in g Azure
Azu r eSQL
SQL Cr eat in g User s an d Gr ou ps in Azu r e
Databases
Dat abases
Creating
Cr eat in g Standard
St an dar dLoad
Load
Balancers
Balan cer s in
in Azure
Azu r e
Back t o M ain
Managing Azure with PowerShell
Course Navigation M an agin g Azu r e Su bscr ipt ion s
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g Ser vice Pr in cipals
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin
Azu re
Azure I mpor t - Modul e Az . Res our c es
$c r edent i al s = New- Obj ec t Mi c r os of t . Az ur e. Commands .
Creating
Cr eat in g Azure
Azu r eSQL
SQL
Databases Ac t i v eDi r ec t or y . PSADPas s wor dCr edent i al - Pr oper t y @{
Dat abases
St ar t Dat e=Get - Dat e; EndDat e=Get - Dat e - Year 2024;
Creating
Cr eat in g Standard
St an dar dLoad
Load Pas s wor d=<Choos e a s t r ong pas s wor d>}
Balancers
Balan cer s in
in Azure
Azu r e
Get - Az AdSer v i c ePr i nc i pal - Di s pl ay Name
M an agin g Azu r e I den t it ies Ser v i c ePr i nc i pal Name
I den
w it h tPow
it ieserwSh
it hellPow er Sh ell
Managing
M an agin g Azure
Azu r e
Subscriptions
Su bscr ipt ion s
Cr eat in g Service
Creating Ser vicePrincipals
Pr in cipals
Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g User s an d Gr ou ps in Azu r e
I n t r odu ct ion t o
Pow er Sh ell 1
Section 2
New- Azur eADUser Requires Di spl ayName,
Passwor dPr of i l e, and UPN.
M an agin g Azu r e w it h
Pow er Sh ell
Retain the Obj ect I D.
Section 3
Man
M anagin
agingg Azu
Azurree
Resourrces
Resou ces w
w itit hh 2
Pow er
Pow erSh
Shell
ell
Requires Di spl ayName,
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es New- Azur eADGr oup Mai l Enabl ed, and
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e
Secur i t yEnabl ed.
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin
Azu re
Azure Again, retain the Obj ect I D.
Creating
Cr eat in g Azure
Azu r eSQL
SQL
Databases
Dat abases
Creating
Cr eat in g Standard
St an dar dLoad
Load 3
Balancers
Balan cer s in
in Azure
Azu r e Add- Azur eADGr oupMember
M an agin g Azu r e I den t it ies Add- Az ur eADGr oupMember - Obj ec t I d
I den
w it h tPow
it ieserwSh
it hellPow er Sh ell
" 62438306- 7c 37- 4638- a72d- 0ee8d9217680"
Managing
M an agin g Azure
Azu r e - Ref Obj ec t I d
Subscriptions
Su bscr ipt ion s
" 0a1068c 0- dbb6- 4537- 9db3- b48f 3e31dd76"
Cr eat in g Service
Creating Ser vicePrincipals
Pr in cipals
Cr eat in g Users
Creating User sand
an dGroups
Gr ou psinin
Azu re
Azure
Back t o M ain
Managing Azure with PowerShell
Course Navigation Rem ot e Adm in ist r at ion
I n t r odu ct ion t o
Pow er Sh ell
Enabl e- Azur eVMPSRemot i ng
Section 2 A With the Enabl e- Azur eVMPSRemot i ng
cm dlet, Azure PowerShell configures the
M an agin g Azu r e w it h
pieces necessary for running com m ands and
Pow er Sh ell
code against target VMs in Azure, m uch like
Section 3
we do on-prem ises. To do this, it perform s
Man
M anagin
agingg Azu
Azurree the following:
Resourrces
Resou ces w
w itit hh - Based on the operating system , it
Pow er
Pow erSh
Shell
ell
ensures WinRM (Windows) or SSH
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es (Linux) is setup.
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e
- It ensures network security group rules
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin are in place to allow com m unication to
Azu re
Azure
the target, again based on
Creating
Cr eat in g Azure
Azu r eSQL
SQL
Databases
Dat abases com m unications type.
Creating
Cr eat in g Standard
St an dar dLoad
Load
- For Linux VMs, it installs PowerShell
Balancers
Balan cer s in
in Azure
Azu r e Core on the target system .
M an agin g Azu r e I den t it ies
I den
w it h tPow
it ieserwSh
it hellPow er Sh ell
Managing
M an agin g Azure
Azu r e
Subscriptions
Su bscr ipt ion s
Cr eat in g Service
Ser vicePrincipals
Pr in cipals
Ent er - AzVM I nvoke- AzVMCommand
Creating
Cr eat in g Users
Creating User sand
an dGroups
Gr ou psinin
Azu re
Azure
Rem
Rem ot
otee Adm
Administration
in ist r at ion
Back t o M ain
Scripting for Azure
Course Navigation Scr ipt in g w it h Azu r e Pow er Sh ell
I n t r odu ct ion t o
Pow er Sh ell Select on the item s below to learn m ore
Section 2 about scripting with Azure PowerShell:
M an agin g Azu r e w it h
Pow er Sh ell Usin g Pow er Sh ell I SE
Section 3
Exporting Outputs to
Usable Form ats
Next St eps
Next
What 's Next?
Back t o M ain
Scripting for Azure
Course Navigation Usin g Pow er Sh ell I SE
M an agin g Azu r e w it h
Pow er Sh ell I SE Tabs
Pow er Sh ell
A PowerShell tab is the environm ent a
Section 3
PowerShell script runs in. We m ay have up to
eight PowerShell tabs open at the sam e tim e.
Script
Scr ipt in
ingg w
w itit hh Azu
Azurree
Pow er
Pow erShShell
ell
Usin
Usingg Pow er Sh ell ISE
PowerShell I SE
Exporting Outputs to
Usable Form ats
Next St eps
Next
Back t o M ain
Scripting for Azure
Course Navigation Usin g Visu al St u dio Code
Script
Scr ipt in
ingg w
w itit hh Azu
Azurree
Pow er
Pow erShShell
ell
Usin
Usingg Pow er Sh ell ISE
PowerShell I SE
Usin
Usingg Visual
Visu al Studio
St u dioCode
Code
Exporting Outputs to
Usable Form ats
Next St eps
Back Next
Back t o M ain
Scripting for Azure
Course Navigation Bu ildin g a Basic Pow er Sh ell Scr ipt
I n t r odu ct ion t o
Pow er Sh ell
Wr i t e- Hos t " Hel l o f r om Li nux Ac ademy ! ! ! "
Section 2
M an agin g Azu r e w it h
Pow er Sh ell We save this file with a . ps1 file extension and run
Section 3
the script by typing the following.
. \ Fi r st . ps1
Scr ipt in g f or Azu r e
Section 4
Script
ipt in
ingg w
w itit hh Azu
Azurree Ch an ge t h e execu t ion policy:
Scr
Pow er
erShShell
ell Set - Ex ec ut i onPol i c y Remot eSi gned
Pow
Ru n t h e scr ipt again :
Usin
Usingg Pow er Sh ell ISE
PowerShell I SE
Fi r s t . ps 1
Usin
Usingg Visual
Visu al Studio
St u dioCode
Code
Building
Bu ildin g aa Basic
BasicPowerShell
Script
Pow er Sh ell Scr ipt
Inputs and Variables
Exporting Outputs to
Usable Form ats
Next St eps
Back Next
Back t o M ain
Scripting for Azure
Course Navigation I n pu t s an d Var iables
I n t r odu ct ion t o
Pow er Sh ell
Section 2 $dat e = get - dat e
Wr i t e- Hos t " Today i s " $dat e
Script
ipt in
ingg w
w itit hh Azu
Azurree # Thi s c mdl et wi l l s how Az ur e Res our c es
Scr
Pow er
Pow erShShell
ell
$Res our c es = Get - Az Res our c e | f t
Usin
Usingg Pow er Sh ell ISE
PowerShell I SE $Res our c es
Usin
Usingg Visual
Visu al Studio
St u dioCode
Code
Building
Bu ildin g aa Basic
BasicPowerShell
Script
Pow er Sh ell Scr ipt
IInputs
n pu t s and
an d Variables
Var iables
Exporting Outputs to
Usable Form ats
Next St eps
Back Next
Back t o M ain
Scripting for Azure
Course Navigation Expor t in g Ou t pu t s t o Usable For m at s
I n t r odu ct ion t o
Pow er Sh ell
Section 2 Get - Az Res our c e | Ex por t - CSV - Pat h
C: \ Sc r i pt s \ Tes t . c s v
Back Next
Back t o M ain
Scripting for Azure
Course Navigation Next St eps
I n t r odu ct ion t o
Pow er Sh ell
Section 2
M an agin g Azu r e w it h
Pow er Sh ell Select the item s below to review the next
Section 3
steps.
Script
Scr ipt in
ingg w
w itit hh Azu
Azurree
Pow er
Pow erShShell
ell
Usin
Usingg Pow er Sh ell ISE
PowerShell I SE
Usin
Usingg Visual
Visu al Studio
St u dioCode
Code Back
Building
Bu ildin g aa Basic
BasicPowerShell
Script
Pow er Sh ell Scr ipt
IInputs
n pu t s and
an d Variables
Var iables
Exporting
Expor t in g Outputs
Ou t pu t stot o
Usable Form
Usable For mats
at s
Next St
Next Steps
eps
Back t o M ain
Scripting for Azure
Course Navigation Wh at 's Next ?
I n t r odu ct ion t o
Pow er Sh ell
Section 2
M an agin g Azu r e w it h
Pow er Sh ell
Section 3
Usin
Usingg Visual
Visu al Studio
St u dioCode
Code I m it at ion :
Building
Bu ildin g aa Basic
BasicPowerShell B Find a blog or website with a PowerShell
Script
Pow er Sh ell Scr ipt script you like. Try to im itate or reproduce it!
IInputs
n pu t s and
an d Variables
Var iables
Exporting
Expor t in g Outputs
Ou t pu t stot o
Usable Form
Usable For mats
at s Docs Ar e Ou r Fr ien ds!!!
Next St
Next Steps
eps C Refer to the official PowerShell
What
Wh at 's
's Next?
Next ?
docum entation as m uch or as little as
necessary.
Back
Back t o M ain