PowerShell Help Commands For Linux Users

Hello!

Microsoft’s Azure keeps growing. Azure isn’t all Windows, but Windows is a great reason to use Azure and a lot of Windows workloads get run there. In today’s Windows, PowerShell is the engineer’s interface to the OS and is often the language behind automation. I decided I needed to know PowerShell to keep up with the industry.

You can run PowerShell on OSX! There are a few differences (e.g. it’s still running inside of the Terminal app so things like ctrl+u work, but in native PowerShell on Windows they don’t), but the basic system is the same. I’ve been running it day to day so I can get used to it.

In bash, there are a bunch of commands I use when I’m trying to figure things out. Like searching the shell aliases or the man pages database. I found plenty of great guides on the basics of PowerShell, but it took some fiddling to find all the parallel pwsh commands for my “figuring things out” commands. I also found a couple handy commands that don’t exist directly in bash (that I know of). Here’s a table:

Update 2019-11: The Out-String uses here are anti-patterns. See my newer post on why. I’ve updated this table with the better way.

Bash PowerShell
man cd
Get-Help cd
man -k 'search string'
Get-Help 'search string'
alias
Get-Alias
Not available. Searches for aliases of a specific cmdlet (‘out-host’ in this example).
Get-Alias -Definition 'out-host'
alias | grep move
Bad:

Get-Alias | Out-String -stream | Select-String -Pattern 'move'

Good:

Get-Alias | Where-Object Name -Match ".*move.*"
env
Get-ChildItem env:
env | grep PATH
Bad:

Get-ChildItem env: | Out-String -stream | sls -Pattern 'PATH'

Good:

Get-ChildItem env: | Where-Object Name -Match ".*PATH.*"
Not available. Wildcard-matches environment variable names but not values (‘PATH’ in this example).
Get-ChildItem env:*PATH*

One other tip is that PowerShell has great tab-completion for commands. It also follows a consistent Verb-Noun convention, so you can try to guess the verb and tab-complete your way to the command. Like if you wanted to know the time, try “get” and hit tab twice and you’ll get a list that has “Get-Date” in it.

Hope that saves you some time!

Adam

If this was helpful and you want to save time by getting “copy and paste” patterns for PowerShell in your inbox, subscribe here.