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

Azure PowerShell Essentials

Course Navigation

Cou r se I n t r odu ct ion


Section 1

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

Scr ipt in g f or Azu r e


Section 4
Course Introduction
Course Navigation Welcom e t o t h e Cou r se

Cou r se I n t r odu ct ion


Section 1

Welcom ee tt oo tt hhee Cou


Welcom Courrse
se
Course Introduction

About the Training


Architect Select on the item s below to learn m ore
I n t r odu ct ion t o
about the course introduction and
Pow er Sh ell Training Architect:
Section 2

Cou r se I n t r odu ct ion


M an agin g Azu r e w it h
Pow er Sh ell
Section 3
Abou t t h e Tr ain in g Ar ch it ect

Scr ipt in g f or Azu r e


Section 4

Next

Back t o M ain
Course Introduction
Course Navigation Cou r se I n t r odu ct ion

Cou r se I n t r odu ct ion


Section 1

Welcom ee tt oo tt hhee Cou


Welcom Courrse
se
Course
Cou r se Introduction
I n t r odu ct ion
About the Training
Architect

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.

Thanks for taking this course. Let 's get started!

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

Cou r se I n t r odu ct ion


Section 1

Welcom ee tt oo tt hhee Cou


Welcom Courrse
se
Course
Cou r se Introduction
I n t r odu ct ion
Aboutt the
Abou t h eTraining
Tr ain in g
Architect
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

Pr of ession al Lif e: Corey Knapp has been an IT professional for


over 22 years, specializing in Microsoft Azure solutions working his
way up from Help Desk to Azure Architect over the past two
decades. His prim ary focus during that tim e has been on
everything from Active Directory to MS Exchange, from Office 365
to Unified Com m unications, and m any other infrastructure and
data center roles. This current role as an Azure Training Architect
has been the single m ost satisfying role of his career, and he looks
forward to sharing his knowledge with you!

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

Benefits of Learning Wh at is Pow er Sh ell?


PowerShell

Basic Com m ands in


PowerShell
I n st allin g Pow er Sh ell
PowerShell Modules

Pow er Sh ell Con cept s


Com m and and Syntax Pow er Sh ell Ver su s Pow er Sh ell Cor e
Basics
The Three Most Im portant
Com m ands in PowerShell
Using Variables Ben ef it s of Lear n in g Pow er Sh ell
Understanding PowerShell
Pipelines

Pow er Sh ell in Azu r e Basic Com m an ds in Pow er Sh ell


Installing the Azure
PowerShell Module
Signing into Azure
Pow er Sh ell M odu les
The Most Im portant Azure
PowerShell Com m ands

Working with Outputs

Using Nested Properties


Filtering Results Next

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

Pow er Sh ell in Azu r e


Installing the Azure
PowerShell Module
Signing into Azure

The Most Im portant Azure


PowerShell Com m ands

Working with Outputs


Azure Active Azure SQL Azure Subscription Azure Resource
Using Nested Properties
Directory Database Group
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 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

Basic Com m ands in


PowerShell
Pow er Sh ell
PowerShell Modules

Pow er Sh ell Con cept s


Com m and and Syntax Windows PowerShell com es installed by default in
Basics every version of Windows since Win7 SP1 and Server
The Three Most Im portant 2008 R2 SP1.
Com m ands in PowerShell
Using Variables
Understanding PowerShell Pow er Sh ell Cor e
Pipelines

Pow er Sh ell in Azu r e


Installing the Azure I n st allin g Pow er Sh ell Cor e
PowerShell Module
Download the MSI package from the Microsoft GitHub
Signing into Azure
release page. Under the Assets section, the MSI file
The Most Im portant Azure looks like
PowerShell Com m ands
Power Shel l - <ver si on>- wi n- <os- ar ch>. msi .
Working with Outputs

Using Nested Properties


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 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

Basic Com m ands in


PowerShell
Pow er Sh ell
PowerShell Modules

Pow er Sh ell Con cept s


Com m and and Syntax Windows PowerShell com es installed by default in
Basics every version of Windows since Win7 SP1 and Server
The Three Most Im portant 2008 R2 SP1.
Com m ands in PowerShell
Using Variables
Understanding PowerShell Pow er Sh ell Cor e
Pipelines

Pow er Sh ell in Azu r e


Installing the Azure I n st allin g Pow er Sh ell Cor e
PowerShell Module
Download the MSI package from the Microsoft GitHub
Signing into Azure
release page. Under the Assets section, the MSI file
The Most Im portant Azure looks like
PowerShell Com m ands
Power Shel l - <ver si on>- wi n- <os- ar ch>. msi .
Working with Outputs

Using Nested Properties


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 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

Pow er Sh ell Versus


PowerShell Ver su s Pow er Sh ell - PS 5.1 is the last full release.
Pow er Sh ell Core
PowerShell Cor e
- Only supports Microsoft OS.
Benefits of Learning - .NET Fram ework dependency.
PowerShell

Basic Com m ands in


PowerShell

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

Working with Outputs

Using Nested Properties


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 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

Basic Com m ands in


PowerShell Tr u st ed by M ost GUI s ar e
Easy
PowerShell Modules Syst em Pow er Sh ell
Au t om at ion
Pow er Sh ell Con cept s Adm in ist r at or s Fr on t En ds
Com m and and Syntax
Basics
The Three Most Im portant
Com m ands in PowerShell Abilit y t o
Using Variables M an ipu lat e Pr epar e f or
Scalable
Understanding PowerShell Ser ver an d M icr osof t
Pipelines M an agem en t
Wor k st at ion Cer t if icat ion s
Pow er Sh ell in Azu r e Com pon en t s
Installing the Azure
PowerShell Module
Signing into Azure

The Most Im portant Azure I n a Nu t sh ell


PowerShell Com m ands PowerShell is a powerful, easy-to-use tool that can create text
Working with Outputs files, create backups, and parse both files and data. It 's also
Using Nested Properties native to Windows, allowing interoperability between
Filtering Results
Windows, Azure, and now both Linux and MacOS.

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

The Most Im portant Azure Copy- I t em


PowerShell Com m ands
and
Working with Outputs
St op- Pr ocess Set - Ex ec ut i onPol i c y
Remove- I t em
Using Nested Properties
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 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

Pow er Sh ell Versus


PowerShell Ver su s
Pow er Sh ell Core
PowerShell Cor e
A m odule is a package containing
Ben ef it sof
Benefits of Learning
Lear n in g
Pow er Sh ell
PowerShell PowerShell com m ands such as cm dlets,
Basic Com
Comm mands
an dsinin
providers, functions, workflows, variables,
Pow er Sh ell
PowerShell and aliases.
PowerShell
Pow er Sh ell Modules
M odu les

Pow er Sh ell Con cept s


Com m and and Syntax
Basics To f in d in st alled m odu les:
The Three Most Im portant Get - Modul e - Li s t Av ai l abl e
Com m ands in PowerShell
Using Variables To f in d alr eady-in st alled m odu les:
Understanding PowerShell Get - Modul e
Pipelines
To f in d all com m an ds in a m odu le:
Pow er Sh ell in Azu r e
Get - Command - Modul e <modul e- name>
Installing the Azure
PowerShell Module
To get h elp f or com m an ds in a m odu le:
Signing into Azure
Get - Hel p <c ommand- name>
The Most Im portant Azure
PowerShell Com m ands To dow n load an d in st all t h e h elp f iles f or com m an ds:
Working with Outputs Updat e- Hel p - Modul e <modul e- name>
Using Nested Properties
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 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

Pow er Sh ell Con cept s Th e Th r ee M ost I m por t an t Com m an ds in


Com m and and Syntax Pow er Sh ell
Basics
The Three Most Im portant
Com m ands in PowerShell Usin g Var iables
Using Variables
Understanding PowerShell
Pipelines
Un der st an din g Pow er Sh ell Pipelin es
Pow er Sh ell in Azu r e
Installing the Azure
PowerShell Module
Signing into Azure

The Most Im portant Azure


PowerShell Com m ands Next
Working with Outputs

Using Nested Properties


Filtering Results

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

Pow er Sh ell Versus


PowerShell Ver su s
Pow er Sh ell Core
PowerShell Cor e
Get - Ser vi ce
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 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

The Most Im portant Azure


PowerShell Com m ands

Working with Outputs

Using Nested Properties


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 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 Con cept s


Com m
Com m and
an d and
an d Syntax
Syn t ax Get - Ser vi ce
Basics
Basics
C This cm dlet gets objects that represent the
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
stopped and started services on a com puter.
Using Variables
Understanding PowerShell
Pipelines

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

Using Nested Properties


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 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

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

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

Pow er Sh ell in Azu r e PS> $l oc


Installing the Azure
Creates a blank variable with the nam e l oc .
PowerShell Module
Signing into Azure
PS> $l oc = Get - Loc at i on
Sends the output of Get Loc at i on to $l oc.
The Most Im portant Azure
PowerShell Com m ands
PS> $l oc | Get - Member - Member Ty pe
Working with Outputs Pr oper t y
Using Nested Properties Uses Get - Member to display inform ation about
the contents of the variable.
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 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

Pow er Sh ell Versus


PowerShell Ver su s
Com m an d-1 | Com m an d-2 | Com m an d-3
Pow er Sh ell Core
PowerShell Cor e

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

Pow er Sh ell Con cept s


I deal f or f ilt er in g object s
Com m
Com m and
an d and
an d Syntax
Syn t ax
Basics
Get a specific piece of inform ation.
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
Understanding
Un der st an din gPowerShell
Pow er Sh ell Tr an sf or m or f or m at in f or m at ion
Pipelines
Pipelin es Change inform ation in som e way.
Pow er Sh ell in Azu r e
Installing the Azure
PowerShell Module
Signing into Azure Object s, n ot t ext
The Most Im portant Azure When running cm dlets in PowerShell, text
PowerShell Com m ands
output is displayed because it is necessary to
Working with Outputs represent objects as text in a console window.
Using Nested Properties
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 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

Pow er Sh ell Versus


PowerShell Ver su s
Com m an d-1 | Com m an d-2 | Com m an d-3
Pow er Sh ell Core
PowerShell Cor e

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

Pow er Sh ell Con cept s


I deal f or f ilt er in g object s
Com m
Com m and
an d and
an d Syntax
Syn t ax
Basics
Get a specific piece of inform ation.
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
Understanding
Un der st an din gPowerShell
Pow er Sh ell Tr an sf or m or f or m at in f or m at ion
Pipelines
Pipelin es Change inform ation in som e way.
Pow er Sh ell in Azu r e
Installing the Azure
PowerShell Module
Signing into Azure Object s, n ot t ext
The Most Im portant Azure When running cm dlets in PowerShell, text
PowerShell Com m ands
output is displayed because it is necessary to
Working with Outputs represent objects as text in a console window.
Using Nested Properties
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 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

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 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

Pow er Sh ell Con cept s


Com m
Com m and
an d and
an d Syntax
Syn t ax Th e M ost I m por t an t Azu r e Pow er Sh ell Com m an ds
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 Wor k in g w it h Ou t pu t s
Understanding
Un der st an din gPowerShell
Pow er Sh ell
Pipelines
Pipelin es
Pow er Sh ell in Azu r e Usin g Nest ed Pr oper t ies
Installing the Azure
PowerShell Module
Signing into Azure
Filt er in g Resu lt s
The Most Im portant Azure
PowerShell Com m ands

Working with Outputs

Using Nested Properties


Filtering Results Next

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

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 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

Pow er Sh ell Con cept s I n st allin g f or t h e act ive u ser :


Com m
I ns t al l - Modul e - Name Az - Al l owCl obber - Sc ope
Com m and
an d and
an d Syntax
Syn t ax
Basics Cur r ent Us er
Basics
The
Th e Three
Th r ee Most
M ost Im
I mportant
por t an t
Com m I n st allin g f or all u ser s (r equ ir es adm in pr ivileges):
Com m ands
an ds in
in PowerShell
Pow er Sh ell
I ns t al l - Modul e - Name - Al l owCl obber - Sc ope
Usingg Variables
Usin Var iables Al l Us er s
Understanding
Un der st an din gPowerShell
Pow er Sh ell
Pipelines
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
I n st allin g Of f lin e
Signing into Azure

The Most Im portant Azure


PowerShell Com m ands

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

Pow er Sh ell Versus


PowerShell Ver su s Sign I n
Pow er Sh ell Core
PowerShell Cor e Sign in in t er act ively
Ben ef it sof
Benefits of Learning
Lear n in g Connect - AzAccount
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 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

Working with Outputs

Using Nested Properties


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 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

Pow er Sh ell Versus


PowerShell Ver su s
Pow er Sh ell Core
PowerShell Cor e For mat - Tabl e
Ben ef it sof
Benefits of Learning
Lear n in g A Default output in PowerShell. Doesn't display
Pow er Sh ell
PowerShell all the inform ation of the requested resource.
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell

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

Using Nested Properties


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 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

Pow er Sh ell Versus


PowerShell Ver su s
Pow er Sh ell Core
PowerShell Cor e Not all pr oper t ies ar e displayed
Ben ef it sof
Benefits of Learning
Lear n in g A Based on the object type, not all of an object 's
Pow er Sh ell
PowerShell
properties are displayed. Why?
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell

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

Pow er Sh ell Versus


PowerShell Ver su s
Pow er Sh ell Core
PowerShell Cor e Wher e- Obj ect cm dlet
Ben ef it sof
of Learning
Lear n in g A Wher e- Obj ec t determ ines which objects to pass
Benefits
Pow er Sh ell
PowerShell along the pipeline by evaluating a script block that
m ay include a reference to an object being filtered.
Basic Com
Comm mands
an dsinin
Pow er Sh ell
PowerShell

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

Cou r se I n t r odu ct ion


Section 1

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

Creating Virtual Machines


using PowerShell in Azure Cr eat in g St or age Accou n t s in Azu r e
Creating Storage Accounts in
Azure
Creating Azure SQL
Cr eat in g Azu r e SQL Dat abases
Databases

Creating Standard Load


Balancers in Azure

M an agin g Azu r e I den t it ies


Cr eat in g St an dar d Load Balan cer s in Azu r e
w it h Pow er Sh ell
Managing Azure
Subscriptions

Creating Service Principals


Next
Creating Users and Groups in
Azure

Rem ote Adm inistration

Scr ipt in g f or Azu r e


Section 4

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

Cou r se I n t r odu ct ion


Section 1 Wh at We'r e Goin g t o Do

In this exercise, we will create an Azure Virtual Machine,


I n t r odu ct ion t o
connect via RDP to the virtual m achine, and install a web server.
Pow er Sh ell
We will do this using only PowerShell.
Section 2

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

Creating Service Principals


I n st all t h e Web Azu r e Pow er Sh ell com m an d:
Creating Users and Groups in
Ser ver I ns t al l - Wi ndows Feat ur e - name
Azure Web- Ser v er
Rem ote Adm inistration - I nc l udeManagement Tool s

Scr ipt in g f or Azu r e


Section 4
Back Next

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

Cou r se I n t r odu ct ion


Section 1 Wh at We'r e Goin g t o Do

In this exercise, we will create a general-purpose v2 standard


I n t r odu ct ion t o
Azure Storage account using only PowerShell.
Pow er Sh ell
Section 2

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

Creating Standard Load Azu r e Pow er Sh ell com m an d:


Balancers in Azure Cr eat e t h e St or age New- Az St or ageAc c ount
M an agin g Azu r e I den t it ies Accou n t - Res our c eGr oupName
w it h Pow er Sh ell $r es our c eGr oup - Name
<ac c ount - name> - Loc at i on
Managing Azure
Subscriptions
eas t us - Sk uName St andar d_LRS
- Ki nd St or ageV2
Creating Service Principals

Creating Users and Groups in


Azure

Rem ote Adm inistration

Scr ipt in g f or Azu r e


Section 4
Back Next

Back t o M ain
Managing Azure with PowerShell
Course Navigation Cr eat in g Azu r e SQL Dat abases

Cou r se I n t r odu ct ion


Section 1
This lesson shows how to create a single database using
PowerShell and the Azure Portal.
I n t r odu ct ion t o
Pow er Sh ell # Set v ar i abl es f or y our s er v er and dat abas e
Section 2
$s ubs c r i pt i onI D = ' <Suns c r i pt i onI D>'
$r es our c eGr oupName = " DBRes our c eGr p- $( Get - Random) "
M an agin g Azu r e w it h
$l oc at i on = " Eas t US"
Pow er Sh ell $admi nLogi n = " az ur eus er "
Section 3 $pas s wor d = " Pas s wor d123! "
$s er v er Name = " my s ql s er v er - $( Get - Random) "
Man
M anagin
agingg Azu
Azurree $dat abas eName = " my Sampl eDat abas e"
Resourrces
Resou ces w
w itit hh
Pow er
Pow erSh
Shell
ell
# Cr eat e an I P Addr es s r ange t hat y ou want t o al l ow
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es # t o ac c es s y our s er v er ( Leav i ng at 0. 0. 0. 0
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e # pr ev ent s out i de- of - Az ur e c onnec t i ons )
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin
Azu re
$s t ar t I p = " 0. 0. 0. 0"
Azure
$endI p = " 0. 0. 0. 0"
Creating
Cr eat in g Azure
Azu r eSQL
SQL
Databases
Dat abases
# Connec t t o Az ur e
Creating Standard Load
Balancers in Azure Connec t - Az Ac c ount
M an agin g Azu r e I den t it ies
w it h Pow er Sh ell # Set s ubs c r i pt i on I D

Managing Azure Set - Az Cont ex t - Subs c r i pt i onI d $s ubs c r i pt i onI d


Subscriptions

Creating Service Principals

Creating Users and Groups in


Azure

Rem ote Adm inistration

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 St an dar d Load Balan cer s in Azu r e

Cou r se I n t r odu ct ion


Section 1
This lesson shows how to create a Standard Load Balancer using
Azure PowerShell.
I n t r odu ct ion t o
Pow er Sh ell # Cr eat e a Res our c e Gr oup
Section 2
$r gName=' My Res our c eGr oupSLB'
$l oc at i on=' eas t us '
M an agin g Azu r e w it h
New- Az Res our c eGr oup - Name $r gName - Loc at i on $l oc at i on
Pow er Sh ell
Section 3 # Cr eat e a Publ i c I P Addr es s

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

Creating Service Principals # Cr eat e a Heal t h Pr obe


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

Cou r se I n t r odu ct ion


Section 1
This lesson shows how to create a single database using
The variables have been set. Let 's begin building the SQL Server.
PowerShell and the Azure Portal.
I n t r odu ct ion t o
Pow er Sh ell # Cr
Seteatv e
ar ia abl
r eses
ourf core gr
y our
oup s er v er and dat abas e
Section 2
$r es
$s ubs our
cr c i eGr
pt i oup
onI D==New- ' <Suns
Az Resc r our
i pt ci eGr
onI oup
D>' - Name
$r es$rourescoureGr coupNam
eGr oupNam
e = e" DBRes
- Loc at ouri on
c eGr$lp-oc$(atGet
i on- Random) "
M an agin g Azu r e w it h
$l oc at i on = " Eas t US"
Pow er Sh ell $adm
# Cr eat
i nLogie a n s er
= v" er
az urwieust h era " s y s t em wi de uni que name
Section 3 $pas s wor d = " Pas s wor d123! "
$s er Az
New- v erSqlNamSer
e v=er" my- sRes
ql sour
er vc er
eGr- $(
oupNam
Get - Random
e )"
Man
M anagin
agingg Azu
Azurree $dat $rabases our
eNam c eGr
e =oupNam
" my Sam e pl` eDat abas e"
Resourrces
Resou ces w
w itit hh - Ser v er Name $s er v er name `
Pow er
Pow erSh
Shell
ell
# Cr -eatLoceatan i onI P$lAddr
oc atesi on
s r `ange t hat y ou want t o al l ow
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es # t o- SQLAdm
ac c es si ni y our
s t r at
s erorvCr
er edent
( Leav i al
i ng
s $(at New-
0. 0.Obj0. ec
0 t - Ty peName
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e # pr Syevsentt ems. Mout
anagem
i de- ent
of - .Az
Autur om
e atc onnec
i on. PSCr
t i onsedent
) i al `
- Ar gument Li s t $admi nLogi n, $( Conv er t To- Sec ur eSt r i ng
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin
Azu re
$s t ar- St
t I rpi ng
= " $pas
0. 0. s0.wor
0" d - As Pl ai nTex t - For c e) )
Azure
$endI p = " 0. 0. 0. 0"
Creating
Cr eat in g Azure
Azu r eSQL
SQL # Cr eat e a s er v er f i r ewal l r ul e t hat al l ows ac c es s f r om
Databases
Dat abases
# tConnec
he s pec t ti o
f i Az
ed urr e
ange
Creating Standard Load
Balancers in Azure NewAz SQLSer
Connec t - Az Acv er
c ount
Fi r ewal l Rul e
M an agin g Azu r e I den t it ies - Res our c eGr oupName $r es our c eGr oupName `
w it h Pow er Sh ell # Set- Ser
s ubs
v ercNam
r i pte i $s
onerI vDer Name `
- Fi r ewal l Rul eName " Al l owed I Ps " - St ar t I pAddr es s
Managing Azure Set - Az Cont$s tex
art t I- pSubs
- EndI
c r i pAddr
pt i onIesds $s
$endI
ubs cpr i pt i onI d
Subscriptions

Creating Service Principals

Creating Users and Groups in


Azure

Rem ote Adm inistration

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 St an dar d Load Balan cer s in Azu r e

Cou r se I n t r odu ct ion


Section 1
This part of shows
lesson the lesson
how focuses ona creating
to create Standardthe load
Load balancer
Balancer and
using
NAT
Azurerules.
PowerShell.
I n t r odu ct ion t o
Pow er Sh ell # Cr eat e a Load
Res ourBal
c eanc
Gr er
oupRul e
Section 2
$r ul e =
gNam e='New- Az LoadBal
My Res our c eGr anc er Rul eConf i g `
oupSLB'
$l -oc
Nam
at ei on='
' my LoadBal
eas t us ' anc er Rul eWeb' - Pr ot oc ol Tc p `
M an agin g Azu r e w it h
- PrAz
New- obeRes $pr
our obe
c eGr -oup
Fr ont endPor
- Name $r tgNam
80 e- Bac k endPor
- Loc at i on t$l 80
oc at` i on
Pow er Sh ell - Fr ont endI pConf i gur at i on $f ei p `
Section 3 # -CrBac
eatk endAddr
e a Publesi sc Pool $bePool
I P Addr es s

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

Cou r se I n t r odu ct ion


Section 1
This lesson shows how to create a single database using
Now that the server has been built, we can create the database.
PowerShell and the Azure Portal.
I n t r odu ct ion t o
Pow er Sh ell # Set
Cr eatv ar
e iGener
abl esal f or
Pur ypos
oure sGen5
er v erdatand dat
abas e abas
wi t he 2 v Cor e
Section 2
$s ubsAz
New- c rSql
i ptDat
i onI D =
abas e '- <Suns
Res ourc rc ieGr
pt ioupNam
onI D>'e
$r es $r
ouresc our
eGr coupNam e = e
eGr oupNam " DBRes
` our c eGr p- $( Get - Random) "
M an agin g Azu r e w it h
$l oc -atSer
i onv er=Nam
" Eas t er
e $s US"v er Name
Pow er Sh ell $adm-i Dat
nLogi abasn eNam
= " aze ur$dat
eus abas
er " eName `
Section 3 $pas -s Edi
wor tdi on= " Gener
Pas s wor d123!
al Pur pos" e `
$s er -v VCor
er Nam e e2 =` " my s ql s er v er - $( Get - Random) "
Man
M anagin
agingg Azu
Azurree $dat -abas eNam e = " atmy iSam
Comput eGener on plGen5
eDat `abas e"
Resourrces
Resou ces w
w itit hh
- Mi ni mumCapac i t y 2 `
Pow er
Pow erSh
Shell
ell
# Cr -eatSam eplan I Pe Addr
eNam " Adves s ur
ent r ange
eWor kt shat
LT" y ou want t o al l ow
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es # t o ac c es s y our s er v er ( Leav i ng at 0. 0. 0. 0
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e # pr ev ent s out i de- of - Az ur e c onnec t i ons )
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin
Azu re
$s t ar t I p = " 0. 0. 0. 0"
Azure
$endI p = " 0. 0. 0. 0"
Creating
Cr eat in g Azure
Azu r eSQL
SQL
Databases
Dat abases
# Connec t t o Az ur e
Creating Standard Load
Balancers in Azure Connec t - Az Ac c ount
M an agin g Azu r e I den t it ies
w it h Pow er Sh ell # Set s ubs c r i pt i on I D

Managing Azure Set - Az Cont ex t - Subs c r i pt i onI d $s ubs c r i pt i onI d


Subscriptions

Creating Service Principals

Creating Users and Groups in


Azure

Rem ote Adm inistration

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 St an dar d Load Balan cer s in Azu r e

Cou r se I n t r odu ct ion


Section 1
With
This lesson
the prerequisites
shows howoutto create
of the away,
Standard
we canLoad
nowBalancer
install the
using
Standard
Azure PowerShell.
Load Balancer.
I n t r odu ct ion t o
Pow er Sh ell # Cr eat e taheRes
Stour
andar
c e dGr Load
oup Bal anc er
Section 2
New-
$r gNamAz LoadBal
e=' My Res anc
ourerc eGr` oupSLB'
$l -oc
Res
at our
i on='c eGr oupNam
eas t us ' e $r gName `
M an agin g Azu r e w it h
- Nam
New- Az eRes ' M y LoadBal
our c eGr oup anc- er
Nam' e` $r gName - Loc at i on $l oc at i on
Pow er Sh ell - SKU St andar d `
Section 3 # -CrLoc
eatatei on $l oci at
a Publ c iI on `
P Addr es s
- Fr ont endI pConf i gur at i on $f ei p `
Man
M anagin
agingg Azu
Azurree - Baci kc endAddr
$publ I p = New- es sAzPool
Publ $bepool
i c I pAddr `es s `
Resourrces
Resou ces w
w itit hh - -Res
Pr obe
our c $preGr obe
oupNam ` e $r gName `
Pow er
Pow erSh
Shell
ell
- -Nam
LoadBal
e ' my anc Publi ngRul
i c I P' e ` $r ul e `
Cr eat in g Vir
Creating t u al Machines
Virtual M ach in es - -Loc
I nboundNat
at i on $l Rul oc ate i $nat
on ` r ul e1, $nat r ul e2, $nat r ul e3
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
# Wi t h t he l oad bal anc er c r eat ed, we c an now c onnec t i t
Azu re
Azure
t#o Crour
eat Aze urt hee Vi
Fr ront
t ual
- EndMacI hi
P nes .
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

Creating Service Principals # Cr eat e a Heal t h Pr obe


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 M an agin g Azu r e I den t it ies w it h Pow er Sh ell

Cou r se I n t r odu ct ion


Section 1

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

M an agin g Azu r e I den t it ies


Rem ot e Adm in ist r at ion
I den
w it h tPow
it ieserwSh
it hellPow er Sh ell
Managing Azure
Subscriptions

Creating Service Principals


Next
Creating Users and Groups in
Azure

Rem ote Adm inistration

Scr ipt in g f or Azu r e


Section 4

Back t o M ain
Managing Azure with PowerShell
Course Navigation M an agin g Azu r e Su bscr ipt ion s

Cou r se I n t r odu ct ion


Section 1

Most Azure users will only ever have a single subscription.


I n t r odu ct ion t o However, there are cases where a user m ight have
Pow er Sh ell m ultiple subscriptions, such as being part of m ore than
Section 2 one organization or being in an organization that has
divided access to certain resources across groupings.
M an agin g Azu r e w it h
Pow er Sh ell
Section 3 Let 's clarify the difference between tenants, users, and
subscriptions in Azure. A t en an t is the Azure Active
Man
M anagin
agingg Azu
Azurree
Resourrces
ces w
w itit hh Directory entity that encom passes the whole organization.
Resou
Pow er
Pow erSh
Shell
ell User s are those accounts that sign in to Azure to create,
Cr eat in g Vir t u al Machines
M ach in es
m anage, and use resources. Su bscr ipt ion s are the
Creating Virtual
uusing
sin g Pow er Sh ell in
PowerShell in Azure
Azu r e agreem ents with Microsoft to use cloud services, including
Cr eat in g Storage
Creating St or ageAccounts
Accou n t sinin Azure. Ever y r esou r ce is associat ed w it h a su bscr ipt ion .
Azu re
Azure
Creating
Cr eat in g Azure
Azu r eSQL
SQL
Databases
Dat abases
Creating
Cr eat in g Standard
St an dar dLoad
Load # Get t i ng a l i s t of Azur e Subs cr i pt i ons
Balancers
Balan cer s in
in Azure
Azu r e

M an agin g Azu r e I den t it ies Get - Az Subs c r i pt i on


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
# Changi ng t he ac t i v e Azur e Subsc r i pt i on
Creating Service Principals
Set - Az Cont ex t - Subsc r i pt i onI d <I D Number >
Creating Users and Groups in
Azure

Rem ote Adm inistration

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 Ser vice Pr in cipals

Cou r se I n t r odu ct ion


Section 1 Microsoft Azure offers service principals instead of having apps
sign in as a fully privileged user.
I n t r odu ct ion t o
An Azure service principal is an identity created for use with apps,
Pow er Sh ell hosted services, and autom ated tools to access Azure resources.
Section 2
There are two types of authentication available for service
M an agin g Azu r e w it h principals: Password-based and Certificate-based.
Pow er Sh ell
Section 3
# Cr eat i ng a Pas s wor d- bas ed aut hent i c at i on
Man
M anagin
agingg Azu
Azurree
Resourrces
Resou ces w
w itit hh
Pow er
erSh
Shell
ell New- Az ADSer v i c ePr i nc i pal - Di s pl ay Name
Pow Ser v i c ePr i nc i pal Name
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 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

Creating Users and Groups in


Azure

Rem ote Adm inistration

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 User s an d Gr ou ps in Azu r e

Cou r se I n t r odu ct ion


User s, Gr ou ps, an d Object I Ds
Section 1

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

Rem ote Adm inistration

Scr ipt in g f or Azu r e


Section 4
Back Next

Back t o M ain
Managing Azure with PowerShell
Course Navigation Rem ot e Adm in ist r at ion

Cou r se I n t r odu ct ion


Section 1 Con n ect in g t o Azu r e VM s u sin g Pow er Sh ell

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

Scr ipt in g f or Azu r e


Section 4
Back

Back t o M ain
Scripting for Azure
Course Navigation Scr ipt in g w it h Azu r e Pow er Sh ell

Cou r se I n t r odu ct ion


Section 1

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

Usin g Visu al St u dio Code


Scr ipt in g f or Azu r e
Section 4
Bu ildin g a Basic Pow er Sh ell Scr ipt
Script
Scr ipt in
ingg w
w itit hh Azu
Azurree
Pow er
Pow erShShell
ell

Using PowerShell ISE


I n pu t s an d Var iables
Using Visual Studio Code

Building a Basic PowerShell


Script Expor t in g Ou t pu t s t o Usable For m at s
Inputs and Variables

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

Cou r se I n t r odu ct ion


Pow er Sh ell I SE:
Section 1
A We can use the Windows PowerShell Integrated
Scripting Environm ent (ISE) to create, run, and
debug com m ands and scripts. The Windows
I n t r odu ct ion t o PowerShell ISE consists of the m enu bar,
Pow er Sh ell Windows PowerShell tabs, the toolbar, script
Section 2 tabs, a Script Pane, a Console Pane, a status bar,
a text-size slider, and context-sensitive help.

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.

Scr ipt in g f or Azu r e


Section 4

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

Using Visual Studio Code

Building a Basic PowerShell


Script
Inputs and Variables

Exporting Outputs to
Usable Form ats

Next St eps

What 's Next?

Next

Back t o M ain
Scripting for Azure
Course Navigation Usin g Visu al St u dio Code

Cou r se I n t r odu ct ion


Visual Studio Code is a code editor. Like m any
Section 1
A other code editors, VS Code adopts a com m on
user interface and layout of an explorer on the
left, showing all of the files and folders a user
I n t r odu ct ion t o has access to. The right side shows the content
Pow er Sh ell of any open files.
Section 2

Pow er Sh ell Ext en sion


M an agin g Azu r e w it h The official PowerShell extension can be
Pow er Sh ell installed from the Ext en sion view or from the
Section 3 VS Code com m and line.

Scr ipt in g f or Azu r e


Section 4

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

Building a Basic PowerShell


Script
Inputs and Variables

Exporting Outputs to
Usable Form ats

Next St eps

What 's Next?

Back Next

Back t o M ain
Scripting for Azure
Course Navigation Bu ildin g a Basic Pow er Sh ell Scr ipt

Cou r se I n t r odu ct ion


Section 1 A Ou r Fir st 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

What 's Next?

Back Next

Back t o M ain
Scripting for Azure
Course Navigation I n pu t s an d Var iables

Cou r se I n t r odu ct ion


Section 1 A Addin g I n pu t s an d Var iables t o
Ou r Scr ipt

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

M an agin g Azu r e w it h We input the cm dlet Get - Dat e to the variable of


Pow er Sh ell $dat e. The output from this Write-Host cm dlet will
Section 3
read as follows (but with the local date and tim e):

Today i s 11/ 23/ 19 3: 29: 44 PM


Scr ipt in g f or Azu r e
Section 4

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

What 's Next?

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

Cou r se I n t r odu ct ion


Section 1 A Addin g I n pu t s an d Var iables t o
Ou r Scr ipt

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

M an agin g Azu r e w it h This com m and gives us a CSV output of the


Pow er Sh ell Get - AzResour ce cm dlet which had been set to the
Section 3 $Resour ces variable.

# Out put i n HTML For mat


Scr ipt in g f or Azu r e
Section 4 Get - Az Res our c e | Conv er t To- HTML | Out - Fi l e
C: \ Sc r i pt s \ Tes t . ht ml
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
Create m ore variables!
Usin
Usingg Visual
Visu al Studio
St u dioCode
Code
Select specific properties for outputs!
Building
Bu ildin g aa Basic
BasicPowerShell
Script
Pow er Sh ell Scr ipt
Set variables for param eters!
IInputs
n pu t s and
an d Variables
Var iables
Exporting
Expor t in g Outputs
Ou t pu t stot o
An yt h in g is possible!
Usable Form
Usable For mats
at s
Next St eps

What 's Next?

Back Next

Back t o M ain
Scripting for Azure
Course Navigation Next St eps

Cou r se I n t r odu ct ion


Section 1

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.

Scr ipt in g f or Azu r e


Section 4 Wh at 's Next ?

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

What 's Next?

Back t o M ain
Scripting for Azure
Course Navigation Wh at 's Next ?

Cou r se I n t r odu ct ion


Section 1

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

Scr ipt in g f or Azu r e


Section 4 Pr act ice:
A The only true way to learn PowerShell is to
Script
Scr ipt in
ingg w
w itit hh Azu
Azurree use it every day. Find a need and try it!
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 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

You might also like