Show Command - PowerShell


Overview

Show-Command is a PowerShell cmdlet that displays detailed information about a specified command, including its syntax, parameters, and examples. It provides a quick and comprehensive reference guide for understanding and using PowerShell commands efficiently.

Syntax

Show-Command [-Name] <String> [-CommandType] <String> [-Module] <String> [-Format] {Text | HTML | Xml}

Options/Flags

  • -Name: Specifies the name of the command to display information about. Required parameter.
  • -CommandType: Filters the displayed commands by their type. Valid values: Cmdlet, Function, Alias, Script.
  • -Module: Filters the displayed commands by the module they belong to.
  • -Format: Specifies the output format. Default: Text.

Examples

  1. Display information about the Get-ChildItem cmdlet:
Show-Command -Name Get-ChildItem
  1. List all cmdlets of a specific type:
Show-Command -CommandType Function
  1. Get information about a command from a specific module:
Show-Command -Name Invoke-WebRequest -Module WebRequest
  1. Output the help in HTML format:
Show-Command -Name Get-Date -Format HTML

Common Issues

  • Command not found: Ensure the command name is entered correctly or that the command is available in the current PowerShell session.
  • Syntax error in output: Some commands may have complex syntax that may not display correctly in the standard text format. Consider using the HTML or Xml output formats for a more structured view.

Integration

Show-Command can be combined with other PowerShell commands to streamline tasks:

  1. Save the command syntax to a file:
Show-Command -Name Get-ChildItem | Out-File -FilePath .\CommandSyntax.txt
  1. Search for commands containing a specific keyword:
Show-Command | Where-Object { $_.Name -like '*Event*' }
  • Get-Command: Retrieves information about commands in the current session.
  • Get-Help: Provides syntax and usage information for a specified command.