Rewiers
Rewiers
Azure CLI 2.0 cheatsheet for Login, Resources, VMs, Resource groups, Storage,
Batch, and Containers.
## Logging in
```
az account list-locations
```
```
RESTRICTED
## Managing VM's
### Start a VM
az vm start --resource-group myResourceGroup --name myVM
```
### Stop a VM
```
az vm stop --resource-group myResourceGroup --name myVM
```
### Deallocate a VM
```
az vm deallocate --resource-group myResourceGroup --name myVM
### Restart a VM
```
az vm restart --resource-group myResourceGroup --name myVM
```
### Redeploy a VM
`
RESTRICTED
```
RESTRICTED
Here are the top 100 PowerShell commands to use and everyone should master:
Displays
information
1 Get-Help about Get-Help Get-Process
PowerShell
commands.
Lists all
available
2 Get-Command Get-Command
commands in
PowerShell.
Retrieves files
and folders in
3 Get-ChildItem Get-ChildItem C:\
a specified
location.
Changes the
current
4 Set-Location Set-Location D:\
working
directory.
Reads the
5 Get-Content content of a Get-Content file.txt
file.
Writes output
6 Out-File Get-Process | Out-File processes.txt
to a file.
Sends output
7 Write-Output Write-Output “Hello, PowerShell!”
to the pipeline.
RESTRICTED
Selects
specific Get-Process | Select-Object Name,
8 Select-Object
properties of CPU
objects.
Filters objects
based on Get-Service | Where-Object
9 Where-Object
specified { $_.Status -eq “Running” }
criteria.
Performs an
operation on
10 ForEach-Object 1..5 | ForEach-Object { $_ * 2 }
each object in
a pipeline.
Formats
Get-Process | Format-Table -
11 Format-Table output as a
AutoSize
table.
Sorts objects
12 Sort-Object by specified Get-Service | Sort-Object Status
properties.
Calculates
properties of “Hello, PowerShell!” | Measure-
13 Measure-Object
objects (e.g., Object -Character
length).
Creates a new
14 New-Item item (file, New-Item newfile.txt -ItemType File
folder, etc.).
Deletes an
15 Remove-Item Remove-Item file.txt
item.
folders.
Renames an
17 Rename-Item Rename-Item file.txt newname.txt
item.
Checks if a file
18 Test-Path or folder Test-Path file.txt
exists.
Retrieves
19 Get-Service Get-Service
services.
Starts a
20 Start-Service Start-Service serviceName
service.
Stops a
21 Stop-Service Stop-Service serviceName
service.
Restarts a
22 Restart-Service Restart-Service serviceName
service.
Retrieves
23 Get-Process Get-Process
processes.
Starts a
24 Start-Process Start-Process notepad
process.
Stops a
25 Stop-Process Stop-Process -Name notepad
process.
RESTRICTED
Retrieves
management Get-WmiObject
26 Get-WmiObject
information Win32_ComputerSystem
using WMI.
Retrieves
27 Get-EventLog event log Get-EventLog -LogName Application
data.
Reads the
28 Get-Content content of a Get-Content file.txt
file.
Writes content
29 Set-Content Set-Content file.txt “New content”
to a file.
Tests network
30 Test-Connection Test-Connection google.com
connectivity.
Comprehensiv
e network
31 Test-NetConnection Test-NetConnection google.com
connectivity
test.
Performs
Invoke-WebRequest https://
32 Invoke-WebRequest HTTP
www.example.com
requests.
Converts
33 ConvertTo-Json objects to Get-Process | ConvertTo-Json
JSON format.
Converts
‘{“Name”:”John”,”Age”:30}’ |
34 ConvertFrom-Json JSON data to
ConvertFrom-Json
objects.
RESTRICTED
Retrieves the
35 Get-Date current date Get-Date
and time.
Creates a new
36 New-Object New-Object PSObject
object.
Reads the
37 Get-Content content of a Get-Content file.txt
file.
Writes content
38 Set-Content Set-Content file.txt “New content”
to a file.
Invokes a
command or
39 Invoke-Expression Invoke-Expression ‘Get-Process’
expression as
if by typing it.
Displays
40 Write-Host messages to Write-Host “Hello, PowerShell!”
the console.
Displays data
41 Out-GridView in a graphical Get-Process | Out-GridView
table.
Sends output
42 Out-Printer Get-Process | Out-Printer
to a printer.
Retrieves host
43 Get-Host Get-Host
information.
the session.
Imports a
45 Import-Module module into Import-Module MyModule
the session.
Removes
imported
46 Remove-Module Remove-Module MyModule
modules from
the session.
Lists available
47 Get-Command Get-Command
commands.
Creates or
49 Set-Alias changes Set-Alias np Notepad
aliases.
Clears the
50 Clear-Host console Clear-Host
screen.
Clears the
51 Clear-Content content of a Clear-Content file.txt
file.
Removes the
52 Clear-Item content of an Clear-Item file.txt
item.
values.
Clears the
contents of
54 Clear-RecycleBin Clear-RecycleBin
the Recycle
Bin.
Compares two
55 Compare-Object sets of Compare-Object object1 object2
objects.
Complete- Completes a
56 Complete-Transaction
Transaction transaction.
Converts
CSV- Get-Content data.csv |
57 ConvertFrom-Csv
formatted data ConvertFrom-Csv
to objects.
Converts
Get-Process | ConvertTo-Csv -
58 ConvertTo-Csv objects to
NoTypeInformation
CSV format.
Debugs a
59 Debug-Process Debug-Process -Id processId
process.
session.
Exports
Get-Alias | Export-Alias -Path
63 Export-Alias aliases to a
aliases.txt
file.
Exports
Get-Process | Export-Clixml
64 Export-Clixml objects to an
process.xml
XML file.
Exports
Get-Process | Export-Csv
65 Export-Csv objects to a
process.csv
CSV file.
Iterates
through
66 ForEach-Object 1..5 | ForEach-Object { $_ * 2 }
objects in the
pipeline.
Formats
output using a
67 Format-Custom Get-Process | Format-Custom
customized
view.
Formats data
as
68 Format-Hex Format-Hex 123
hexadecimal
values.
Formats
69 Format-List output as a list Get-Process | Format-List
of properties.
Formats
Get-Process | Format-Table -
70 Format-Table output as a
AutoSize
table.
RESTRICTED
Formats
output as a
71 Format-Wide table with a Get-Process | Format-Wide
single wide
column.
Retrieves
72 Get-Acl access control Get-Acl file.txt
lists (ACLs).
Sets access
73 Set-Acl control lists Set-Acl file.txt -AclObject $aclObj
(ACLs).
Get- Retrieves
75 AuthenticodeSignatu digital Get-AuthenticodeSignature file.exe
re signatures.
Retrieves
76 Get-ChildItem items in a Get-ChildItem C:\
location.
Retrieves the
current
77 Get-Clipboard Get-Clipboard
clipboard
contents.
Gets
78 Get-Command Get-Command
commands.
Retrieves
79 Get-ComputerInfo computer Get-ComputerInfo
information.
RESTRICTED
Retrieves the
80 Get-Content content of an Get-Content file.txt
item.
Retrieves
81 Get-Credential stored Get-Credential
credentials.
Retrieves
82 Get-Culture culture Get-Culture
information.
Retrieves the
83 Get-Date current date Get-Date
and time.
Retrieves
84 Get-Event Get-Event
events.
Retrieves the
85 Get-History command Get-History
history.
Retrieves host
86 Get-Host Get-Host
information.
Retrieves
87 Get-HotFix installed Get-HotFix
hotfixes.
Retrieves
88 Get-Item Get-Item
items.
item. Length
Retrieves
90 Get-Job background Get-Job
jobs.
Retrieves the
91 Get-Location current Get-Location
location.
Retrieves
92 Get-Member members of Get-Process | Get-Member
an object.
Lists the
modules
93 Get-Module Get-Module
imported into
the session.
Retrieves the
Get-WmiObject
operating
94 Get-OSVersion Win32_OperatingSystem | Select-
system
Object Caption
version.
Retrieves
95 Get-Process Get-Process
processes.
Generates
Get-Random -Minimum 1 -Maximum
96 Get-Random random
100
numbers.
Retrieves
97 Get-Service Get-Service
services.
Retrieves user
interface
99 Get-UICulture Get-UICulture
culture
information.
10 Retrieves
Get-Unique Get-ChildItem | Get-Unique
0 unique items.