Introduction to PowerShell for Unix People by Powershell.org - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

4. commands detail - a

alias (list all the aliases)

The Powershell equivalent of typing alias at the bash prompt is:

img77.png

alias (set an alias)

At it’s simplest, the powershell equivalent of the unix ‘alias’ when it’s usedto set an alias is ‘set-alias’

img78.png

However, there’s a slight wrinkle….

In unix, you can do this

img79.png

If you try doing this in Powershell, it doesn’t work so well. If you do this:

img80.png

…then you get this error:

img81.png

A way around this is to create a function instead:

img82.png

You can then create an alias for the function:

img83.png

apropos

apropos is one of my favourite bash commands, not so much for what it does…but because I like the word ‘apropos’.

I’m not sure it exists on all flavours of *nix, but in bash apropos returns a list of all the man pages which have something to do with what you’re searching for. If apropos isn’t implemented on your system you can use man -k instead.

Anyway on bash, if you type:

img84.png

…then you get:

img85.png

The Powershell equivalent of apropos or man -k is simply get-help

img86.png

This is quite a nice feature of PowerShell compared to Bash. If get-help in Powershell shell scores a ‘direct hit’ (i.e. you type something like get-help debug-process) it will show you the help for that particular function. If you type something more vague, it will show you a list of all the help pages you might be interested in.

By contrast if you typed man process at the Bash prompt, you’d just get

img87.png