get-command
cmdLet returns an array of objects that are derived from System.Management.Automation.CommandInfo
. These objects can then be queried about the individual commands. get-command
returns all installed commands. PS:\> get-command *-command CommandType Name Version Source ----------- ---- ------- ------ Function Find-Command 1.0.0.1 PowerShellGet Cmdlet Get-Command 3.0.0.0 Microsoft.PowerShell.Core Cmdlet Invoke-Command 3.0.0.0 Microsoft.PowerShell.Core Cmdlet Measure-Command 3.1.0.0 Microsoft.PowerShell.Utility Cmdlet Show-Command 3.1.0.0 Microsoft.PowerShell.Utility Cmdlet Trace-Command 3.1.0.0 Microsoft.PowerShell.Utility
-syntax
switch allows to quickly get an overview of a cmdLet's or function's parameters, their types and if they're optional or mandatory PS Users\Rene> get-command get-process -syntax Get-Process [[-Name] <string[]>] [-ComputerName <string[]>] [-Module] [-FileVersionInfo] [<CommonParameters>] Get-Process [[-Name] <string[]>] -IncludeUserName [<CommonParameters>] Get-Process -Id <int[]> -IncludeUserName [<CommonParameters>] Get-Process -Id <int[]> [-ComputerName <string[]>] [-Module] [-FileVersionInfo] [<CommonParameters>] Get-Process -InputObject <Process[]> -IncludeUserName [<CommonParameters>] Get-Process -InputObject <Process[]> [-ComputerName <string[]>] [-Module] [-FileVersionInfo] [<CommonParameters>]
(get-command mkdir).definition
System.Management.Automation.CommandInfo
object that get-object
returns can be passed to the constructor of System.Management.Automation.CommandMetadata
. The object that this constructor creates can then be used to query some meta data about a command. # # Get the two CommandInfo objects: # PS C:\> $lsCommand = get-command ls PS C:\> $stopProcessCommand = get-command stop-process # # Get the object's respective CommandMetadata objects: # PS C:\> $lsMeta = new-object System.Management.Automation.CommandMetadata($lsCommand) PS C:\> $stopProcessMeta = new-object System.Management.Automation.CommandMetadata($stopProcessCommand) # # ls is an alias for get-childItem: # PS C:\> $lsMeta.Name Get-ChildItem # # Show a cmdLet's help URI # PS C:\> $stopProcessMeta.HelpUri https://go.microsoft.com/fwlink/?LinkID=113412
-asJob
parameter name: get-command -parameterName asJob
get-command
to check if an executable (here: the C# compiler) is present and prints yes
if so, no
otherwise. if ($null = get-command -errorAction ignore csc) {'yes'} else {'no'}