Guy recommends :
Free Permissions
Analyzer Tool

Solarwinds Free Download of Permissions Analyzer

 

View the effective permissions for a folder or shared drive. Free download try it now!


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 later, you don't need to download any extra files, just: 'Add Feature' --> Windows PowerShell.  However, for older operating systems, 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 or later, I recommend choosing the ISE (Integrated Scripting Engine) version, it will save 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: Free WMI Monitor for PowerShellSolarwinds Free WMI Monitor for PowerShell

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft's 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. Give this WMI monitor a try - it's free.

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*.

Get-Command -Module

Firstly list your modules with Get-Module.  Make your selection, for example, ISE.

# PowerShell Get-Command Module info
Clear-Host
Get-Module ISE

Here is another example which imports a modules then checks the cmdlets.

$Baskets = "PSDiagnostics"
Import-Module $Baskets
Get-Command -Module $Baskets

SolarWinds Firewall Browser Solarwinds Free Firewall Browser

Here is an utility where you can review firewall settings such as access control lists (ACL), or troubleshoot problems with network address translation (NAT).

Other reasons to download this SolarWinds Firewall Browser include managing requests to change your firewall settings, testing firewall rules before you go live, and querying settings with the browser's powerful search options.

Guy recommends that you download a copy of the SolarWinds free Firewall Browser.

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*"}

 

Summary of Get-Command Cmdlet

Get-Command is a great way to research what PowerShell cmdlets exist.  It helps to filter with -Noun -Verb, you can also use * wildcards.

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 Help About   • Get-Help

PowerShell v 3.0   • Set-ExecutionPolicy   • Get-Command   • Cmdlet scripts   • Import-Module

PowerShell Version Check   • Backtick   • PowerShell examples   • PowerShell ISE   • 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

Site Home

Guy Recommends: WMI Monitor for PowershellSolarwinds WMI Monitor

Windows Management Instrumentation (WMI) is most useful for PowerShell scripting.

SolarWinds have produced this Free WMI Monitor to 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

Author: Guy Thomas Copyright © 1999-2013 Computer Performance LTD All rights reserved.

Please report a broken link, or an error to: