What have I learned so far?
Get-Item, Set-Location.
The PowerShell glossary defines "noun" as "The word that follows the hyphen in a Windows PowerShell cmdlet name."
docs.microsoft.com/en-us/powershe…
Short names are better for exploring.
docs.microsoft.com/en-us/powershe…
I love that you get these AND long names for making descriptive scripts.
In PowerShell, the interface is objects. Programs (cmdlets) pipe objects to each other.
Ah, rich data! Ah, no string parsing!
- command-line parsing
- help, triggered by -?
- definitions of some common parameters
- output formatting
- error handling options (coooool)
Set it to "SilentlyContinue" when you don't want errors printed to stderr.
For instance, test whether a directory exists:
if (Get-Location -Path $ofInterest -ErrorAction SilentlyContinue) { … }
Format-Table -Property name,value,etc -wrap
Out-Host -paging (like piping to 'less')
Get-Member (like reflection -- see methods & properties)
That makes the error reasonable
There are case-sensitive versions that add a C.
"Yes" -eq "yes"
but NOT
"Yes -ceq "yes"
I guess this is a benefit of using short names instead of symbols for the operators.
`n
(backtick n)
Instead of \n
Cool! Did not expect!
I love happy surprises like this. It's like Ruby, except easier to install.
bash:
echo -ne "\033]0;Changed Title\007"
PowerShell:
$host.ui.RawUI.WindowTitle = “Changed Title”
💗
Because it's reserving STDOUT for data that might be piped to another Linux command.
Git writes to STDERR for lack of Write-Host.
PowerShell distinguishes between data output and messages to the user. 💝
gist.github.com/jessitron/c44d…