Basics

>The Background

>Cmdlets

Get-Command set* #show cmdlets starting with set
Get-Command #show all the cmdlets that powershell knows about
Get-Command -verb "keyword" #show all the verbs with the corresponding keyword
Get-Command -noun "keyword" #show all the corresponding nouns

cmdlet -whatif #show what will happen after this cmdlet is executed

>Cmdlet Aliases

Many cmdlets have aliases making them much easier to use

#We can use the alias command to show all the aliases that are there
alias

CommandType     Name
-----------     ----                                              
Alias           ? -> Where-Object                                 
Alias           % -> ForEach-Object                               
Alias           cd -> Set-Location

[redacted for brevity]

#To get alias for a specific cmdlet
Get-Alias -definition <cmdlet>f

>Getting Help

help [cmdlet/ alias]
help [cmdlet] -detailed
help [cmdlet] -examples
help [cmdlet] -full
help [cmdlet] -online 

>The Pipeline

#Show a list of methods and properties of each object 
cmdlet | Get-Member
cmdlet | Format-List 
cmdlet | Format-List -property [property]
cmdlet | Format-List -property * 

>Working with objects in the pipeline

<aside> 👉 ForEach-Object % {$_})

</aside>

Get-Process -name nc | % {stop-process $_}
Get-Process -name nc | ForEach-Object {stop-process $_}

100, 200, 500 | % {$_ * 50}
100, 200, 500 | ForEach-Object {$_ * 50}

<aside> 👉 Where-Object ? {$_})

</aside>

Get-Command | Get-Member
Get-Command | Where-Object {$_.status -eq "running"}
Get-Command | ? {$_.status -eq "running"}

>Environment Variables

ls env:
ls variable: