Guy recommends :
Free Solarwinds
VM Console

Solarwinds VM Console Free Download

Find out which of your VMs are a waste of space and which VMs need more resources.



Windows PowerShell Get-Command Cmdlet

Windows PowerShell Get-Command Cmdlet

Get-Command is like a waiter who will not only take your order for a cmdlet but also recommend other tasty PowerShell dishes. 

If you are new to PowerShell Get-Command is a good cmdlet for practicing the basics.  For more experienced users this page will help you discover more of the 250+ PowerShell v 2.0 cmdlets.

Windows PowerShell Get-Command Topics

 ♣

PowerShell Pre-requisites and Checklist

In the case of Windows 7 and Server 2008, you don't need to download any extra files, just 'Add Feature' Windows PowerShell.  However, for older operating systems, installing can be confusing because there are different versions of PowerShell for XP, Windows Server 2003 and Vista.  For such legacy systems only, you need to download PowerShell from Microsoft's site.

Once you have installed PowerShell 2.0, I recommend choosing the ISE (Integrated Scripting Engine) version, it will save you buying a text editor.

Get-Command On Its Own

Get-Command is one of the few built-in cmdlets that returns results on its own.  However the list is so long that the art of using Get-Command is to select the best filter.

# PowerShell Get-Command
Clear-Host
Get-Command

Note:  This will return all the cmdlets and their aliases.  Maybe you need a filter?  If so see below.

Get-Command Wildcards

Example 1: Listing PowerShell commands beginning with set.

# PowerShell Get-Command Wildcard*
Clear-Host
Get-Command set*

Example 2: Suppose the cmdlet you are searching for begins with a letter between M and S

# PowerShell Get-Command Range
Clear-Host
Get-Command [M-S]*

Example 3: You think it may have 'Serv' somewhere in the command.

# PowerShell Get-Command
Clear-Host
Get-Command *serv*

Guy Recommends: WMI Monitor and It's Free!Solarwinds Free WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.  Fortunately, Solarwinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your PowerShell scripts.  Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory or Exchange Server.

Download your free copy of WMI Monitor

Get-Command with -noun and -verb

As you get to know PowerShell better so you become familiar with verbs such as 'Set' or 'Get' and nouns such as 'Process' or 'Computer'.  This is why I now prefer to filter Get-Command with -noun or -verb.  One of my greatest successes was finding 'Restart-Service'.  I had used start and stop-service, but when I tried this filter I unearthed the useful Restart-Service.

# PowerShell Get-Command Nouns
Clear-Host
Get-Command -noun Service

Also Verbs

# PowerShell Get-Command Nouns
Clear-Host
Get-Command -verb S*

Note: I could have chosen -verb Set, but I wanted to show you that -verb also take wildcards*.

Further Research on Get-Command

Research Get-Command Parameters

# PowerShell Get-Command Parameters
Clear-Host
Get-Help Get-Command

Checking the help file may reveal useful parameters and techniques, for instance -CommandType can filter for just Aliases see here.

Talking of parameters, Get-Command can find cmdlets that support a particular parameter, for example -computerName.

# Find a PowerShell Cmdlet by Its Parameter
Clear-Host
Get-Command | where { $_.parameters.keys -match "Computer*"}

You can also filter on parameter.definition.

Clear-Host
Get-Command | where { $_.definition -like "*Index*"}

 

If you like this page then please share it with your friends

 


See more Windows PowerShell tutorials

PShell Home  • Introduction   • Dreams   • 3 Key Commands   • PowerShell v 3.0

Process example   • Backtick   • Get-Command   • PowerShell ISE   • Cmdlet scripts

Windows PowerShell    • Set-ExecutionPolicy   • PowerShell examples   • Get-Member

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.

Download my ebook:Getting Started with PowerShell
Getting Started with PowerShell - only $9.25

You get 36 topics organized into these 3 sections:
   1) Getting Started
   2) Real-life tasks
   3) Examples of Syntax.

In addition to the ebook, you get a PDF version of this  Introduction to PowerShell ebook  It runs to 120 pages of A4.

 *


Custom Search

Guy Recommends: WMI Monitor and It's Free!Solarwinds WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.

Fortunately, Solarwinds have created the Free WMI Monitor so that you can actually see and understand these gems of performance information.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

 

Home Copyright © 1999-2012 Computer Performance LTD All rights reserved

Please report a broken link, or an error.