liveBook · Manning

External command

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

An external command is an executable program invoked from PowerShell rather than a PowerShell cmdlet or function.

An external command is an executable program launched from PowerShell instead of a native PowerShell cmdlet or function. Existing utilities such as ping, nslookup, ifconfig, ipconfig, grep, bash, sed, and awk can run from the PowerShell prompt, with their results displayed as they would be in the older shell. This lets administrators keep using familiar tools while gradually adopting PowerShell commands. section 4.7

Use external commands when a familiar utility already solves the task:

  • Run ping for connectivity checks, or use the native Test-Connection cmdlet when you need more options or more flexible output. section 4.7
  • Remember that command discovery can return external applications as well as cmdlets; restrict Get-Command searches by command type, verb, or noun when you need only cmdlets. section 3.4

Invoke a command stored in a variable

A PowerShell variable can hold an executable name, while other variables hold its action and arguments: $exe = "func"; $action = "new"; $language = "powershell"; $template = "HttpTrigger"; $name = "myFunc"; & $exe $action -l $language -t $template -n $name. section 4.7

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Defines external commands, demonstrates their cross-platform availability, and contrasts ping with Test-Connection without detailing parser behavior.
Examples
Uses ping, nslookup, ifconfig, ipconfig, grep, bash, sed, awk, and a variable-based func invocation.
What it assumes
Assumes familiarity with some command-line utilities while explaining how they coexist with PowerShell commands.
What you can do after
Apply it via PowerShell by running familiar external utilities and identifying them separately from cmdlets.
How it connects
Connects external commands with PowerShell cmdlets, command discovery, command types, and shell utilities.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.