On this page I define the word cmdlet to mean a built-in PowerShell command, with a single verb-noun pair. There is another shade of meaning to cmdlet, namely a series of commands, usually more than one line, stored
in a text file with a .ps1 extension. This page deals with the first meaning and
includes a review of PowerShell's built-in cmdlets.
Here are the 13 sections of PowerShell's built-in cmdlets.
a) get-help. This
is the best command to explore the built-in PowerShell library. As with many cmdlets, it begins with the verb 'get'. Example: get-help
alias. Remember that get-help supports wildcards,
for example type: get-help *object.
b) get-command. Returns a list of available commands. Get-command really is the entire command, I was expecting more, but this cmdlet is
only two words,
get and command separated by a hyphen. You may wish to try a wild
card, for example get-command c*
c) get-host. Displays information about the PowerShell host. (Not to be confused with hostname.)
Try this command to check your version number.
d) get-culture. Shows you information about the
regional settings of the host (as defined in the Regional Settings of the Control Panel)
e) get-uiculture Returns information about the regional settings
of the host as defined by the selected language on a multi-language operating system.
a) get-Member. This is by far the most
important cmdlet. get-Member enumerates properties, methods and type information of the objects; for example:
get-WmiObject | get-Member Special note, the
pipeline symbol displays as ¦ in PowerShell, but as | in notepad.
See a whole page on get-Member
b) foreach-object. The purpose of this cmdlet is to loop
through multiple instances, such as disk drives. Foreach applies a block of script to each object in the pipeline. For example;
Note that the type of bracket is significant, () or {} each have a distinct role
(condition) {script block}. Also note the + which not only adds numbers, but also is the same symbol that concatenates text.
c)
where-object (Often abbreviated to plain 'where') filters the input from the pipeline, allowing operation on only certain objects. For example:
d)
new-object. Creates instances of .NET or COM objects. New-object is particularly useful for creating VBScript objects. For example, network objects, Active Directory objects and also applications such as IE.
e) select-object. Filters objects based on parameters set in the cmdlet command string
f) group-Object.
An undervalued cmdlet. Handy for collecting objects based on a common property
value.
g) sort-Object. Sequences object based on a property value
Guy Recommends: SolarWinds Engineer's Toolset v10
The Engineer's Toolset v10 provides a
comprehensive console of utilities for troubleshooting computer problems. Guy says
it helps me monitor what's occurring on the network, and the tools
teaches me more about how the system literally operates.
There are so many good gadgets, it's like having free rein of a
sweetshop. Thankfully the utilities are displayed logically: monitoring, discovery, diagnostic, and Cisco tools.
Download your copy of the Engineer's Toolset v 10
Understanding Aliases is easy.
Just start with the built-in Aliases, for example gci (get-Childitem). Also ft (format table) for example, get-Process * |ft name, handles, cpu -auto
a) set-alias Maps an alias to a command,
for example where you wish to create your own alias.
b) get-alias
Returns a list of all defined aliases
c) new-alias Creates a new alias
d) export-alias Outputs the system alias table in CSV format
e) import-alias Updates the system alias table from a CSV file
a)
add-content Appends content to a file or creates a file if one does not exist
b) clear-content Removes content from a file while leaving the file intact
c) get-content Returns the content of a file as a
sequence of lines
d) set-content Replaces the content of a file with new content
Guy Recommends: SolarWinds LANSurveyor
LANSurveyor will produce a neat diagram of your network topology. But that's
just the start;
LANSurveyor can
create an inventory of the hardware and software
of your machines and network devices. Other neat features include dynamic
update for when you add new devices to your network. I also love the ability to export
the diagrams
to Microsoft Visio.
Finally, Guy bets that if you take a free trial of LANSurveyor then you will
find a device on your network that you had forgotten about, or someone else
installed without you realizing!
b) new-variable Creates a new variable with a
specified name and value
c) set-variable Updates or creates a new variable with a specified name and value; useful at the end of a pipeline for storing objects into a variable for later use
d)
remove-variable Removes a variable definition from the variable list
e) clear-variable Removes the value of a variable but leaves its definition in place ( i.e., sets its value to null)
PowerShell has a rich source of built-in verb-noun pairs. While you probably only need about 20, it's worthwhile acquainting yourself with what commands are available. Guy says waste no
opportunity to increase your cmdlet repertoire.
If you see an error of any kind, do let me know. Please report any factual mistakes, grammatical errors or broken links, I will be happy to not only to correct the fault, but also to give you credit.
*
Guy
Recommends: Orion's NPM - Network Performance Monitor
Orion's performance monitor is designed for detecting network outages.
A network-centric
view make it easy to see what's working, and what needs your attention.
This utility guides you through troubleshooting by indicating whether the
root cause is faulty equipment or resource overload.