Skip to content

Instantly share code, notes, and snippets.

@IngmarBoddington
Created April 23, 2021 10:32
Show Gist options
  • Save IngmarBoddington/fc84745768003b961d4763677497711b to your computer and use it in GitHub Desktop.
Save IngmarBoddington/fc84745768003b961d4763677497711b to your computer and use it in GitHub Desktop.
SETUP (OSX)
=====
install using homebrew
brew install --cask powershell
Run with
pwsh
Visual Studio / Code has an extenstion for editing
BASICS / CMDLETS
================
Get extended version information
$PSVersionTable
Can access peroperties using dot notation
$PSVersionTable.PSVersion
Uses objects not text for piping generally
cmdlets are compiled commands running on a common runtime
Very specific naming formats Verb-Noun
Use Get-Verb to see allowed verbs
Get-Command - list all cmdlets, can use filters (can combine below)
Get-Command -Noun <string>
Get-Command -Verb <string>
Get-Command -ParameterType <string> #Get commands which use a parameter class (good to know as types are important here)
Get-Help - Get help info (just use 'help' which comes with pagination - space here to scroll by page)
Get-Help -Name <string> or Get-Help <string> #Help info for specific command
-Full #This flag returns a detailed help page. It specifies information like parameters, inputs, and outputs that you don't get in the standard response.
-Detailed #This flag's response looks like the standard response, but it includes a section for parameters.
-Examples #This flag returns only examples, if any exist.
-Online #This flag opens a web page for your command.
-Parameter #This flag requires a parameter name as an argument. It lists a specific parameter's properties.
Get-Member - drill down into objects
<cmdlet> | Get-Member - Show drill down of return from command(s)
Select-Object - use this to filter objects
<cmdlet> | Get-Member | Select-Objects <string> #string is comma delimited col names or *
-MemberType <string> #filter this on member type
For grepping use . for any character and * for any characters
For piping use | but remember these are objects
#Single line comment
<#
Comment Block
#>
USEFUL CMDLETS
==============
Get-Process
-Name <string>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment