commands detail - m

mailx

To send an email from the PowerShell command line, this worked for me:

  1. $PSEmailServer = "exchange_server.domain.co.uk"
  2. send-mailmessage -to eden.hazard@gmail.com -from matt@here.co.uk -subject "Hello"

man

The Powershell equivalent of man is:

  1. get-help

get-help has the following built-in aliases:

  • help
  • man

There are a couple of things to note about get-help.

There are two much-used options: -full and -examples. They both do exactly what you’d expect, I think. To give some idea of scale, on my laptop get-help get-process currently returns just over a screenful of information, wherease get-help -get-process -full returns 9 screenfuls.

The help text can be brought up-to-date by running update-help from the command line.

You can easily write your own help text for your own functions, by using a feature called comment-based help.

man -k

In *nix man -k allows you to search through all the man pages for mentions of a particular keyword. It returns a list of the man pages which are relevant to the word you’ve searched for. On some systems, it’s aliased to apropos. Anyway, man -k disk would perhaps return lines for, say, du, df and lsvol (at the time of typing I don’t have a Linux install to hand, so I’m guessing here.)

There’s no seperate command for this in PowerShell, because the get-help command does this by default if it doesn’t find a direct match.

So, if you type get-help get-process you would get this:

  1. NAME
  2. Get-Process
  3. SYNOPSIS
  4. Gets the processes that are running on the local computer or a remote computer.
  5. SYNTAX
  6. Get-Process [[-Name] <String[]>] [-ComputerName <String[]>] [-FileVersionInfo] [-Module] [<CommonParameters>]
  7. Get-Process [-ComputerName <String[]>] [-FileVersionInfo] [-Module] -InputObject <Process[]> [<CommonParameters>]
  8. etc....

…whereas if you typed get-help process you would get a list of help topics related to ‘process’[1]:

  1. Name Category Synopsis
  2. ---- -------- --------
  3. Debug-Process Cmdlet Debugs one or more processes running on the local computer.
  4. Get-Process Cmdlet Gets the processes that are running on the local computer or a remote computer.
  5. Start-Process Cmdlet Starts one or more processes on the local computer.
  6. Stop-Process Cmdlet Stops one or more running processes.
  7. Wait-Process Cmdlet Waits for the processes to be stopped before accepting more input.

more

Powershell incorporates a more command which broadly works in the console similarly to the unix more.

The Powershell more is a wrapper for more.com[2], which is an old Microsoft implementation of more.

more doesn’t work in the ISE, but you can however easily scroll back through output by pressing ‘Ctrl’ and ‘Up-arrow’ at the same time. This then allows you to use all the arrow keys (as well as Ctrl-c and Ctrl-V to cut and paste) to navigate around the output from previous commands.

mv

The PowerShell equivalent of mv is:

  1. Rename-Item

Footnotes


[1] To be honest, I actually did get-help process | select name, category, synopsis | ft -a to tidy up the output for the e-book.

[2] I found that in my current PowerShell installs, there wasn’t much information on more. The get-help command returned the barest of details.

To see what the command actually does I ran:

  1. get-command more | select definition | format-list