PowerShell Flashcards

1
Q

Connect to Azure

A

Connect-AzAccount

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Create Virtual Machine

A

New-AzVm

   - ResourceGroupName 
   - Name 
   - Credential 
   - Location 
   - Image <img>

Example:
New-AzVM -ResourceGroupName az104-prereq-rg -Name vm1 -Credential (Get-Credential) -Image MicrosoftWindowsServer:WindowsServer:2022-datacenter-azure-edition-core:latest -Size Standard_DC1s_v2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Delete a VM

A

Remove-AzVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Stop/Start a VM

A

Stop-AzVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName
Start-AzVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Get the SKUs of available and unavailable compute resources

A

Get-AzComputeResourceSku -Location

Get-AzComputeResourceSku “southeastasia”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Allow SSH into VM

A

Add these params to New-AzVM command.

  • OpenPorts 22
  • PublicIpAddressName “testvm-01”

*Note port 22 allows for SSH

ssh @
e.g. ssh bob@205.22.16.5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

variable declaration

A
$loc = "East Us"
$iterations = 3
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Variables and objects

A

Variables can hold objects

$adminCredential = Get-Credential

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Using variables

A

$loc = “East US”

New-AzResourceGroup -Name “MyResourceGroup” - Location $loc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Loops

A

For ($i = 1; $i -lt 3; $i++)
{
$i
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Script Params

A

.\setupEnvironment.ps1 -size 5 -location “East US”

param([string]$location, [int]$size)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What VM Images are available in region?

A

What publishers are available?
Get-AzVMImagePublisher
-Location

What offers are available?
Get-AzVMImageOffer
-Location
-PublisherName

What VMImages are available?
Get-AzVMImageSku
   -Location 
   -PublisherName 
   -Offer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly