0
0
PowerShellscripting~5 mins

Command discovery (Get-Command) in PowerShell

Choose your learning style9 modes available
Introduction

Get-Command helps you find commands available in PowerShell. It shows what commands you can run.

You want to see if a command exists before using it.
You need to find commands related to a task, like 'file' or 'process'.
You want to discover commands from modules you installed.
You want to check the type of a command (cmdlet, function, alias).
Syntax
PowerShell
Get-Command [-Name] <string[]> [-Module <string[]>] [-CommandType <CommandTypes[]>] [-ListImported] [-All] [<CommonParameters>]

-Name lets you specify the command name or pattern (wildcards allowed).

-CommandType filters by type like Cmdlet, Function, Alias, Application.

Examples
Finds the command named 'Get-Process'.
PowerShell
Get-Command -Name Get-Process
Finds all commands with 'Service' in their name.
PowerShell
Get-Command -Name *Service*
Lists all cmdlets available in the session.
PowerShell
Get-Command -CommandType Cmdlet
Shows commands from the specified module.
PowerShell
Get-Command -Module Microsoft.PowerShell.Management
Sample Program

This script finds the 'Get-Process' command, then all commands with 'Service' in their name, and finally shows the first 3 aliases.

PowerShell
Get-Command -Name Get-Process
Get-Command -Name *Service*
Get-Command -CommandType Alias | Select-Object -First 3
OutputSuccess
Important Notes

You can use wildcards (*) to find commands with partial names.

Get-Command shows commands from all loaded modules by default.

Use Select-Object to limit output if many commands are found.

Summary

Get-Command helps you find and explore commands in PowerShell.

You can search by name, type, or module.

It is useful to discover what commands you can use for your tasks.