From bab20445321ee56dae71aac8dabfdc3bd0abd8b8 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Sat, 9 Nov 2024 14:26:17 -0600 Subject: [PATCH] Fix note about executable extensions --- .../Microsoft.PowerShell.Core/Get-Command.md | 76 +++++++------ .../Microsoft.PowerShell.Core/Get-Command.md | 105 ++++++++++-------- .../Microsoft.PowerShell.Core/Get-Command.md | 105 ++++++++++-------- 3 files changed, 155 insertions(+), 131 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/Get-Command.md b/reference/5.1/Microsoft.PowerShell.Core/Get-Command.md index a4e740c7edee..0b5f9f6eb1ff 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/Get-Command.md +++ b/reference/5.1/Microsoft.PowerShell.Core/Get-Command.md @@ -2,7 +2,7 @@ external help file: System.Management.Automation.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Core -ms.date: 01/21/2023 +ms.date: 11/09/2024 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/get-command?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-Command @@ -39,14 +39,15 @@ aliases, functions, filters, scripts, and applications. `Get-Command` gets the c PowerShell modules and commands that were imported from other sessions. To get only commands that have been imported into the current session, use the **ListImported** parameter. -Without parameters, `Get-Command` gets all of the cmdlets, functions, and aliases installed on the -computer. `Get-Command *` gets all types of commands, including all of the non-PowerShell files in -the Path environment variable (`$env:Path`), which it lists in the Application command type. +Without parameters, `Get-Command` gets all the cmdlets, functions, and aliases installed on the +computer. `Get-Command *` gets all types of commands, including all the non-PowerShell files in the +Path environment variable (`$env:PATH`), which it lists in the Application command type. `Get-Command` that uses the exact name of the command, without wildcard characters, automatically imports the module that contains the command so that you can use the command immediately. To enable, disable, and configure automatic importing of modules, use the `$PSModuleAutoLoadingPreference` -preference variable. For more information, see [about_Preference_Variables](About/about_Preference_Variables.md). +preference variable. For more information, see +[about_Preference_Variables](About/about_Preference_Variables.md). `Get-Command` gets its data directly from the command code, unlike `Get-Help`, which gets its information from help topics. @@ -74,7 +75,7 @@ Get-Command -ListImported ### Example 3: Get cmdlets and display them in order -This command gets all of the cmdlets, sorts them alphabetically by the noun in the cmdlet name, and +This command gets all the cmdlets, sorts them alphabetically by the noun in the cmdlet name, and then displays them in noun-based groups. This display can help you find the cmdlets for a task. ```powershell @@ -93,7 +94,7 @@ Get-Command -Module Microsoft.PowerShell.Security, Microsoft.PowerShell.Utility ### Example 5: Get information about a cmdlet This command gets information about the `Get-AppLockerPolicy` cmdlet. It also imports the -**AppLocker** module, which adds all of the commands in the **AppLocker** module to the current +**AppLocker** module, which adds all the commands in the **AppLocker** module to the current session. ```powershell @@ -103,28 +104,30 @@ Get-Command Get-AppLockerPolicy When a module is imported automatically, the effect is the same as using the Import-Module cmdlet. The module can add commands, types and formatting files, and run scripts in the session. To enable, disable, and configuration automatic importing of modules, use the `$PSModuleAutoLoadingPreference` -preference variable. For more information, see [about_Preference_Variables](../Microsoft.PowerShell.Core/About/about_Preference_Variables.md). +preference variable. For more information, see +[about_Preference_Variables](../Microsoft.PowerShell.Core/About/about_Preference_Variables.md). ### Example 6: Get the syntax of a cmdlet This command uses the **ArgumentList** and **Syntax** parameters to get the syntax of the -`Get-ChildItem` cmdlet when it is used in the Cert: drive. The Cert: drive is a PowerShell drive -that the Certificate Provider adds to the session. +`Get-ChildItem` cmdlet when it's used in the Cert: drive. The Cert: drive is a PowerShell drive that +the Certificate Provider adds to the session. ```powershell Get-Command -Name Get-Childitem -Args Cert: -Syntax ``` -When you compare the syntax displayed in the output with the syntax that is displayed when you omit -the **Args** (**ArgumentList**) parameter, you'll see that the **Certificate provider** adds a dynamic -parameter, **CodeSigningCert**, to the `Get-ChildItem` cmdlet. +When you compare the syntax displayed in the output with the syntax that's displayed when you omit +the **Args** (**ArgumentList**) parameter, you'll see that the **Certificate provider** adds a +dynamic parameter, **CodeSigningCert**, to the `Get-ChildItem` cmdlet. -For more information about the Certificate provider, see [about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). +For more information about the Certificate provider, see +[about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). ### Example 7: Get dynamic parameters The command in the example uses the `Get-DynamicParameters` function to get the dynamic parameters -that the Certificate provider adds to the `Get-ChildItem` cmdlet when it is used in the Cert: drive. +that the Certificate provider adds to the `Get-ChildItem` cmdlet when it's used in the Cert: drive. ```powershell function Get-DynamicParameters @@ -151,7 +154,7 @@ cmdlet by another cmdlet or a provider. ### Example 8: Get all commands of all types This command gets all commands of all types on the local computer, including executable files in the -paths of the **Path** environment variable (`$env:path`). +paths of the **Path** environment variable (`$env:PATH`). ```powershell Get-Command * @@ -169,7 +172,7 @@ This command gets cmdlets that have a parameter whose name includes Auth and who Get-Command -ParameterName *Auth* -ParameterType AuthenticationMechanism ``` -You can use a command like this one to find cmdlets that let you specify the method that is used to +You can use a command like this one to find cmdlets that let you specify the method that's used to authenticate the user. The **ParameterType** parameter distinguishes parameters that take an **AuthenticationMechanism** @@ -189,7 +192,7 @@ CommandType Name ModuleName Alias dir -> Get-ChildItem ``` -Although it is typically used on cmdlets and functions, `Get-Command` also gets scripts, functions, +Although it's typically used on cmdlets and functions, `Get-Command` also gets scripts, functions, aliases, and executable files. The output of the command shows the special view of the **Name** property value for aliases. The @@ -220,7 +223,8 @@ the **All** parameter, `Get-Command` gets all commands with the specified name a execution precedence order. To run a command other than the first one in the list, type the fully qualified path to the command. -For more information about command precedence, see [about_Command_Precedence](About/about_Command_Precedence.md). +For more information about command precedence, see +[about_Command_Precedence](About/about_Command_Precedence.md). ### Example 12: Get the name of a module that contains a cmdlet @@ -235,7 +239,7 @@ The command uses the **ModuleName** property of all commands. Microsoft.PowerShell.Utility ``` -This command format works on commands in PowerShell modules, even if they are not imported into the +This command format works on commands in PowerShell modules, even if they're not imported into the session. ### Example 13: Get cmdlets and functions that have an output type @@ -288,10 +292,10 @@ get the first net adapter that the cmdlet returns. Indicates that this cmdlet gets all commands, including commands of the same type that have the same name. By default, `Get-Command` gets only the commands that run when you type the command name. -For more information about the method that PowerShell uses to select the command to run when -multiple commands have the same name, see [about_Command_Precedence](About/about_Command_Precedence.md). -For information about module-qualified command names and running commands that do not run by default -because of a name conflict, see [about_Modules](About/about_Modules.md). +For more information about the order that PowerShell searches for commands, see +[about_Command_Precedence](About/about_Command_Precedence.md). For information about +module-qualified command names and running commands that don't run by default because of a name +conflict, see [about_Modules](About/about_Modules.md). This parameter was introduced in Windows PowerShell 3.0. @@ -311,15 +315,15 @@ Accept wildcard characters: False ### -ArgumentList -Specifies an array of arguments. This cmdlet gets information about a cmdlet or function when it is +Specifies an array of arguments. This cmdlet gets information about a cmdlet or function when it's used with the specified parameters ("arguments"). The alias for **ArgumentList** is **Args**. To detect dynamic parameters that are available only when certain other parameters are used, set the value of **ArgumentList** to the parameters that trigger the dynamic parameters. To detect the dynamic parameters that a provider adds to a cmdlet, set the value of the -**ArgumentList** parameter to a path in the provider drive, such as WSMan:, HKLM:, or Cert:. When -the command is a PowerShell provider cmdlet, enter only one path in each command. The provider +**ArgumentList** parameter to a path in the provider drive, such as `WSMan:`, `HKLM:`, or `Cert:`. +When the command is a PowerShell provider cmdlet, enter only one path in each command. The provider cmdlets return only the dynamic parameters for the first path the value of **ArgumentList**. For information about the provider cmdlets, see [about_Providers](About/about_Providers.md). @@ -348,18 +352,19 @@ The acceptable values for this parameter are: - `All`: Gets all command types. This parameter value is the equivalent of `Get-Command *`. -- `Application`: Gets non-PowerShell files in paths listed in the **Path** environment variable - (`$env:path`), including `.txt`, `.exe`, and `.dll` files. For more information about the **Path** - environment variable, see [about_Environment_Variables](About/about_Environment_Variables.md). +- `Application`: Searches folders in the `$env:PATH` environment variable for non-PowerShell + executable files. On Windows, executable files have a file extension that is listed in the + `$env:PATHEXT` environment variable. For more information, see + [about_Environment_Variables](About/about_Environment_Variables.md). - `Cmdlet`: Gets all cmdlets. - `ExternalScript`: Gets all `.ps1` files in the paths listed in the **Path** environment variable - (`$env:path`). + (`$env:PATH`). - `Filter` and `Function`: Gets all PowerShell advanced and simple functions and filters. -- `Script`: Gets all script blocks. To get PowerShell scripts (`.ps1 `files), use the +- `Script`: Gets all script blocks. To get PowerShell scripts (`.ps1` files), use the `ExternalScript` value. - `Workflow`: Gets all workflows. For more information about workflows, see Introducing Windows @@ -409,7 +414,7 @@ A module specification is a hashtable that has the following keys. - `RequiredVersion` - Specifies an exact, required version of the module. This can't be used with the other Version keys. -You cannot specify the **FullyQualifiedModule** parameter in the same command as a **Module** +You can't specify the **FullyQualifiedModule** parameter in the same command as a **Module** parameter. The two parameters are mutually exclusive. ```yaml @@ -629,7 +634,8 @@ Accept wildcard characters: True This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](About/about_CommonParameters.md). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](About/about_CommonParameters.md). ## INPUTS @@ -641,7 +647,7 @@ You can pipe command names to this cmdlet. ### System.Management.Automation.CommandInfo -This cmdlet returns objects derived from the **CommandInfo** class. The type of object that is +This cmdlet returns objects derived from the **CommandInfo** class. The type of object that's returned depends on the type of command that `Get-Command` gets. ### System.Management.Automation.AliasInfo diff --git a/reference/7.4/Microsoft.PowerShell.Core/Get-Command.md b/reference/7.4/Microsoft.PowerShell.Core/Get-Command.md index df297cdbf4dc..1ee0f3b0ff4e 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/Get-Command.md +++ b/reference/7.4/Microsoft.PowerShell.Core/Get-Command.md @@ -2,7 +2,7 @@ external help file: System.Management.Automation.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Core -ms.date: 01/21/2023 +ms.date: 11/09/2024 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/get-command?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-Command @@ -40,14 +40,15 @@ aliases, functions, filters, scripts, and applications. `Get-Command` gets the c PowerShell modules and commands that were imported from other sessions. To get only commands that have been imported into the current session, use the **ListImported** parameter. -Without parameters, `Get-Command` gets all of the cmdlets, functions, and aliases installed on the -computer. `Get-Command *` gets all types of commands, including all of the non-PowerShell files in -the Path environment variable (`$env:Path`), which it lists in the Application command type. +Without parameters, `Get-Command` gets all the cmdlets, functions, and aliases installed on the +computer. `Get-Command *` gets all types of commands, including all the non-PowerShell files in the +Path environment variable (`$env:PATH`), which it lists in the Application command type. `Get-Command` that uses the exact name of the command, without wildcard characters, automatically imports the module that contains the command so that you can use the command immediately. To enable, disable, and configure automatic importing of modules, use the `$PSModuleAutoLoadingPreference` -preference variable. For more information, see [about_Preference_Variables](About/about_Preference_Variables.md). +preference variable. For more information, see +[about_Preference_Variables](About/about_Preference_Variables.md). `Get-Command` gets its data directly from the command code, unlike `Get-Help`, which gets its information from help topics. @@ -75,7 +76,7 @@ Get-Command -ListImported ### Example 3: Get cmdlets and display them in order -This command gets all of the cmdlets, sorts them alphabetically by the noun in the cmdlet name, and +This command gets all the cmdlets, sorts them alphabetically by the noun in the cmdlet name, and then displays them in noun-based groups. This display can help you find the cmdlets for a task. ```powershell @@ -94,7 +95,7 @@ Get-Command -Module Microsoft.PowerShell.Security, Microsoft.PowerShell.Utility ### Example 5: Get information about a cmdlet This command gets information about the `Get-AppLockerPolicy` cmdlet. It also imports the -**AppLocker** module, which adds all of the commands in the **AppLocker** module to the current +**AppLocker** module, which adds all the commands in the **AppLocker** module to the current session. ```powershell @@ -104,28 +105,30 @@ Get-Command Get-AppLockerPolicy When a module is imported automatically, the effect is the same as using the Import-Module cmdlet. The module can add commands, types and formatting files, and run scripts in the session. To enable, disable, and configuration automatic importing of modules, use the `$PSModuleAutoLoadingPreference` -preference variable. For more information, see [about_Preference_Variables](../Microsoft.PowerShell.Core/About/about_Preference_Variables.md). +preference variable. For more information, see +[about_Preference_Variables](../Microsoft.PowerShell.Core/About/about_Preference_Variables.md). ### Example 6: Get the syntax of a cmdlet This command uses the **ArgumentList** and **Syntax** parameters to get the syntax of the -`Get-ChildItem` cmdlet when it is used in the Cert: drive. The Cert: drive is a PowerShell drive -that the Certificate Provider adds to the session. +`Get-ChildItem` cmdlet when it's used in the Cert: drive. The Cert: drive is a PowerShell drive that +the Certificate Provider adds to the session. ```powershell Get-Command -Name Get-Childitem -Args Cert: -Syntax ``` -When you compare the syntax displayed in the output with the syntax that is displayed when you omit -the **Args** (**ArgumentList**) parameter, you'll see that the **Certificate provider** adds a dynamic -parameter, **CodeSigningCert**, to the `Get-ChildItem` cmdlet. +When you compare the syntax displayed in the output with the syntax that's displayed when you omit +the **Args** (**ArgumentList**) parameter, you'll see that the **Certificate provider** adds a +dynamic parameter, **CodeSigningCert**, to the `Get-ChildItem` cmdlet. -For more information about the Certificate provider, see [about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). +For more information about the Certificate provider, see +[about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). ### Example 7: Get dynamic parameters The command in the example uses the `Get-DynamicParameters` function to get the dynamic parameters -that the Certificate provider adds to the `Get-ChildItem` cmdlet when it is used in the Cert: drive. +that the Certificate provider adds to the `Get-ChildItem` cmdlet when it's used in the Cert: drive. ```powershell function Get-DynamicParameters @@ -152,7 +155,7 @@ cmdlet by another cmdlet or a provider. ### Example 8: Get all commands of all types This command gets all commands of all types on the local computer, including executable files in the -paths of the **Path** environment variable (`$env:path`). +paths of the **Path** environment variable (`$env:PATH`). ```powershell Get-Command * @@ -170,7 +173,7 @@ This command gets cmdlets that have a parameter whose name includes Auth and who Get-Command -ParameterName *Auth* -ParameterType AuthenticationMechanism ``` -You can use a command like this one to find cmdlets that let you specify the method that is used to +You can use a command like this one to find cmdlets that let you specify the method that's used to authenticate the user. The **ParameterType** parameter distinguishes parameters that take an **AuthenticationMechanism** @@ -190,7 +193,7 @@ CommandType Name ModuleName Alias dir -> Get-ChildItem ``` -Although it is typically used on cmdlets and functions, `Get-Command` also gets scripts, functions, +Although it's typically used on cmdlets and functions, `Get-Command` also gets scripts, functions, aliases, and executable files. The output of the command shows the special view of the **Name** property value for aliases. The @@ -209,9 +212,13 @@ Get-Command -Name dir -Syntax ```Output dir (alias) -> Get-ChildItem -dir [[-Path] ] [[-Filter] ] [-Include ] [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] [-Attributes ] [-FollowSymlink] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] +dir [[-Path] ] [[-Filter] ] [-Include ] [-Exclude ] [-Recurse] +[-Depth ] [-Force] [-Name] [-Attributes ] [-FollowSymlink] +[-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] -dir [[-Filter] ] -LiteralPath [-Include ] [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] [-Attributes ] [-FollowSymlink] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] +dir [[-Filter] ] -LiteralPath [-Include ] [-Exclude ] [-Recurse] +[-Depth ] [-Force] [-Name] [-Attributes ] [-FollowSymlink] +[-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] ``` ### Example 12: Get all instances of the Notepad command @@ -239,7 +246,8 @@ the **All** parameter, `Get-Command` gets all commands with the specified name a execution precedence order. To run a command other than the first one in the list, type the fully qualified path to the command. -For more information about command precedence, see [about_Command_Precedence](About/about_Command_Precedence.md). +For more information about command precedence, see +[about_Command_Precedence](About/about_Command_Precedence.md). ### Example 13: Get the name of a module that contains a cmdlet @@ -254,7 +262,7 @@ The command uses the **ModuleName** property of all commands. Microsoft.PowerShell.Utility ``` -This command format works on commands in PowerShell modules, even if they are not imported into the +This command format works on commands in PowerShell modules, even if they're not imported into the session. ### Example 14: Get cmdlets and functions that have an output type @@ -300,21 +308,20 @@ first net adapter that the cmdlet returns. ### Example 16: Get commands using a fuzzy match -In this example, the name of the command deliberately has a typo as 'get-commnd'. -Using the `-UseFuzzyMatching` switch, the cmdlet determined that the best match -was `Get-Command` followed by other native commands on the system that were a -similar match. +In this example, the name of the command deliberately has a typo as 'get-commnd'. Using the +`-UseFuzzyMatching` switch, the cmdlet determined that the best match was `Get-Command` followed by +other native commands on the system that were a similar match. ```powershell Get-Command get-commnd -UseFuzzyMatching ``` ```Output -CommandType Name Version Source ------------ ---- ------- ------ -Cmdlet Get-Command 6.2.0.0 Microsoft.PowerShell.Core -Application getconf 0.0.0.0 /usr/bin/getconf -Application command 0.0.0.0 /usr/bin/command +CommandType Name Version Source +----------- ---- ------- ------ +Cmdlet Get-Command 6.2.0.0 Microsoft.PowerShell.Core +Application getconf 0.0.0.0 /usr/bin/getconf +Application command 0.0.0.0 /usr/bin/command ``` ## PARAMETERS @@ -324,10 +331,10 @@ Application command 0.0.0.0 /u Indicates that this cmdlet gets all commands, including commands of the same type that have the same name. By default, `Get-Command` gets only the commands that run when you type the command name. -For more information about the method that PowerShell uses to select the command to run when -multiple commands have the same name, see [about_Command_Precedence](About/about_Command_Precedence.md). -For information about module-qualified command names and running commands that do not run by default -because of a name conflict, see [about_Modules](About/about_Modules.md). +For more information about the order that PowerShell searches for commands, see +[about_Command_Precedence](About/about_Command_Precedence.md). For information about +module-qualified command names and running commands that don't run by default because of a name +conflict, see [about_Modules](About/about_Modules.md). This parameter was introduced in Windows PowerShell 3.0. @@ -347,15 +354,15 @@ Accept wildcard characters: False ### -ArgumentList -Specifies an array of arguments. This cmdlet gets information about a cmdlet or function when it is +Specifies an array of arguments. This cmdlet gets information about a cmdlet or function when it's used with the specified parameters ("arguments"). The alias for **ArgumentList** is **Args**. To detect dynamic parameters that are available only when certain other parameters are used, set the value of **ArgumentList** to the parameters that trigger the dynamic parameters. To detect the dynamic parameters that a provider adds to a cmdlet, set the value of the -**ArgumentList** parameter to a path in the provider drive, such as WSMan:, HKLM:, or Cert:. When -the command is a PowerShell provider cmdlet, enter only one path in each command. The provider +**ArgumentList** parameter to a path in the provider drive, such as `WSMan:`, `HKLM:`, or `Cert:`. +When the command is a PowerShell provider cmdlet, enter only one path in each command. The provider cmdlets return only the dynamic parameters for the first path the value of **ArgumentList**. For information about the provider cmdlets, see [about_Providers](About/about_Providers.md). @@ -384,18 +391,19 @@ The acceptable values for this parameter are: - `All`: Gets all command types. This parameter value is the equivalent of `Get-Command *`. -- `Application`: Gets non-PowerShell files in paths listed in the **Path** environment variable - (`$env:path`), including `.txt`, `.exe`, and `.dll` files. For more information about the **Path** - environment variable, see [about_Environment_Variables](About/about_Environment_Variables.md). +- `Application`: Searches folders in the `$env:PATH` environment variable for non-PowerShell + executable files. On Windows, executable files have a file extension that is listed in the + `$env:PATHEXT` environment variable. For more information, see + [about_Environment_Variables](About/about_Environment_Variables.md). - `Cmdlet`: Gets all cmdlets. - `ExternalScript`: Gets all `.ps1` files in the paths listed in the **Path** environment variable - (`$env:path`). + (`$env:PATH`). - `Filter` and `Function`: Gets all PowerShell advanced and simple functions and filters. -- `Script`: Gets all script blocks. To get PowerShell scripts (`.ps1 `files), use the +- `Script`: Gets all script blocks. To get PowerShell scripts (`.ps1` files), use the `ExternalScript` value. These values are defined as a flag-based enumeration. You can combine multiple values together to @@ -442,7 +450,7 @@ A module specification is a hashtable that has the following keys. - `RequiredVersion` - Specifies an exact, required version of the module. This can't be used with the other Version keys. -You cannot specify the **FullyQualifiedModule** parameter in the same command as a **Module** +You can't specify the **FullyQualifiedModule** parameter in the same command as a **Module** parameter. The two parameters are mutually exclusive. ```yaml @@ -677,7 +685,7 @@ Accept wildcard characters: False ### -UseFuzzyMatching Indicates using a fuzzy matching algorithm when finding commands. The order of the output is from -closest match to least likely match. Wildcards should not be used with fuzzy matching as it will +closest match to least likely match. Wildcards shouldn't be used with fuzzy matching as it will attempt to match commands that may contain those wildcard characters. ```yaml @@ -714,7 +722,8 @@ Accept wildcard characters: True This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](About/about_CommonParameters.md). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](About/about_CommonParameters.md). ## INPUTS @@ -726,7 +735,7 @@ You can pipe command names to this cmdlet. ### System.Management.Automation.CommandInfo -This cmdlet returns objects derived from the **CommandInfo** class. The type of object that is +This cmdlet returns objects derived from the **CommandInfo** class. The type of object that's returned depends on the type of command that `Get-Command` gets. ### System.Management.Automation.AliasInfo @@ -751,7 +760,7 @@ PowerShell includes the following aliases for `Get-Command`: - All platforms: - `gcm` - + - When more than one command that has the same name is available to the session, `Get-Command` returns the command that runs when you type the command name. To get commands that have the same name, listed in run order, use the **All** parameter. For more information, see diff --git a/reference/7.5/Microsoft.PowerShell.Core/Get-Command.md b/reference/7.5/Microsoft.PowerShell.Core/Get-Command.md index 47a79d70243d..ef90f3bbe25d 100644 --- a/reference/7.5/Microsoft.PowerShell.Core/Get-Command.md +++ b/reference/7.5/Microsoft.PowerShell.Core/Get-Command.md @@ -2,7 +2,7 @@ external help file: System.Management.Automation.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Core -ms.date: 01/21/2023 +ms.date: 11/09/2024 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/get-command?view=powershell-7.5&WT.mc_id=ps-gethelp schema: 2.0.0 title: Get-Command @@ -40,14 +40,15 @@ aliases, functions, filters, scripts, and applications. `Get-Command` gets the c PowerShell modules and commands that were imported from other sessions. To get only commands that have been imported into the current session, use the **ListImported** parameter. -Without parameters, `Get-Command` gets all of the cmdlets, functions, and aliases installed on the -computer. `Get-Command *` gets all types of commands, including all of the non-PowerShell files in -the Path environment variable (`$env:Path`), which it lists in the Application command type. +Without parameters, `Get-Command` gets all the cmdlets, functions, and aliases installed on the +computer. `Get-Command *` gets all types of commands, including all the non-PowerShell files in the +Path environment variable (`$env:PATH`), which it lists in the Application command type. `Get-Command` that uses the exact name of the command, without wildcard characters, automatically imports the module that contains the command so that you can use the command immediately. To enable, disable, and configure automatic importing of modules, use the `$PSModuleAutoLoadingPreference` -preference variable. For more information, see [about_Preference_Variables](About/about_Preference_Variables.md). +preference variable. For more information, see +[about_Preference_Variables](About/about_Preference_Variables.md). `Get-Command` gets its data directly from the command code, unlike `Get-Help`, which gets its information from help topics. @@ -75,7 +76,7 @@ Get-Command -ListImported ### Example 3: Get cmdlets and display them in order -This command gets all of the cmdlets, sorts them alphabetically by the noun in the cmdlet name, and +This command gets all the cmdlets, sorts them alphabetically by the noun in the cmdlet name, and then displays them in noun-based groups. This display can help you find the cmdlets for a task. ```powershell @@ -94,7 +95,7 @@ Get-Command -Module Microsoft.PowerShell.Security, Microsoft.PowerShell.Utility ### Example 5: Get information about a cmdlet This command gets information about the `Get-AppLockerPolicy` cmdlet. It also imports the -**AppLocker** module, which adds all of the commands in the **AppLocker** module to the current +**AppLocker** module, which adds all the commands in the **AppLocker** module to the current session. ```powershell @@ -104,28 +105,30 @@ Get-Command Get-AppLockerPolicy When a module is imported automatically, the effect is the same as using the Import-Module cmdlet. The module can add commands, types and formatting files, and run scripts in the session. To enable, disable, and configuration automatic importing of modules, use the `$PSModuleAutoLoadingPreference` -preference variable. For more information, see [about_Preference_Variables](../Microsoft.PowerShell.Core/About/about_Preference_Variables.md). +preference variable. For more information, see +[about_Preference_Variables](../Microsoft.PowerShell.Core/About/about_Preference_Variables.md). ### Example 6: Get the syntax of a cmdlet This command uses the **ArgumentList** and **Syntax** parameters to get the syntax of the -`Get-ChildItem` cmdlet when it is used in the Cert: drive. The Cert: drive is a PowerShell drive -that the Certificate Provider adds to the session. +`Get-ChildItem` cmdlet when it's used in the Cert: drive. The Cert: drive is a PowerShell drive that +the Certificate Provider adds to the session. ```powershell -Get-Command -Name Get-ChildItem -Args Cert: -Syntax +Get-Command -Name Get-Childitem -Args Cert: -Syntax ``` -When you compare the syntax displayed in the output with the syntax that is displayed when you omit -the **Args** (**ArgumentList**) parameter, you'll see that the **Certificate provider** adds a dynamic -parameter, **CodeSigningCert**, to the `Get-ChildItem` cmdlet. +When you compare the syntax displayed in the output with the syntax that's displayed when you omit +the **Args** (**ArgumentList**) parameter, you'll see that the **Certificate provider** adds a +dynamic parameter, **CodeSigningCert**, to the `Get-ChildItem` cmdlet. -For more information about the Certificate provider, see [about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). +For more information about the Certificate provider, see +[about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). ### Example 7: Get dynamic parameters The command in the example uses the `Get-DynamicParameters` function to get the dynamic parameters -that the Certificate provider adds to the `Get-ChildItem` cmdlet when it is used in the Cert: drive. +that the Certificate provider adds to the `Get-ChildItem` cmdlet when it's used in the Cert: drive. ```powershell function Get-DynamicParameters @@ -152,7 +155,7 @@ cmdlet by another cmdlet or a provider. ### Example 8: Get all commands of all types This command gets all commands of all types on the local computer, including executable files in the -paths of the **Path** environment variable (`$env:path`). +paths of the **Path** environment variable (`$env:PATH`). ```powershell Get-Command * @@ -170,7 +173,7 @@ This command gets cmdlets that have a parameter whose name includes Auth and who Get-Command -ParameterName *Auth* -ParameterType AuthenticationMechanism ``` -You can use a command like this one to find cmdlets that let you specify the method that is used to +You can use a command like this one to find cmdlets that let you specify the method that's used to authenticate the user. The **ParameterType** parameter distinguishes parameters that take an **AuthenticationMechanism** @@ -190,7 +193,7 @@ CommandType Name ModuleName Alias dir -> Get-ChildItem ``` -Although it is typically used on cmdlets and functions, `Get-Command` also gets scripts, functions, +Although it's typically used on cmdlets and functions, `Get-Command` also gets scripts, functions, aliases, and executable files. The output of the command shows the special view of the **Name** property value for aliases. The @@ -209,9 +212,13 @@ Get-Command -Name dir -Syntax ```Output dir (alias) -> Get-ChildItem -dir [[-Path] ] [[-Filter] ] [-Include ] [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] [-Attributes ] [-FollowSymlink] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] +dir [[-Path] ] [[-Filter] ] [-Include ] [-Exclude ] [-Recurse] +[-Depth ] [-Force] [-Name] [-Attributes ] [-FollowSymlink] +[-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] -dir [[-Filter] ] -LiteralPath [-Include ] [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] [-Attributes ] [-FollowSymlink] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] +dir [[-Filter] ] -LiteralPath [-Include ] [-Exclude ] [-Recurse] +[-Depth ] [-Force] [-Name] [-Attributes ] [-FollowSymlink] +[-Directory] [-File] [-Hidden] [-ReadOnly] [-System] [] ``` ### Example 12: Get all instances of the Notepad command @@ -239,7 +246,8 @@ the **All** parameter, `Get-Command` gets all commands with the specified name a execution precedence order. To run a command other than the first one in the list, type the fully qualified path to the command. -For more information about command precedence, see [about_Command_Precedence](About/about_Command_Precedence.md). +For more information about command precedence, see +[about_Command_Precedence](About/about_Command_Precedence.md). ### Example 13: Get the name of a module that contains a cmdlet @@ -254,7 +262,7 @@ The command uses the **ModuleName** property of all commands. Microsoft.PowerShell.Utility ``` -This command format works on commands in PowerShell modules, even if they are not imported into the +This command format works on commands in PowerShell modules, even if they're not imported into the session. ### Example 14: Get cmdlets and functions that have an output type @@ -300,21 +308,20 @@ first net adapter that the cmdlet returns. ### Example 16: Get commands using a fuzzy match -In this example, the name of the command deliberately has a typo as 'get-commnd'. -Using the `-UseFuzzyMatching` switch, the cmdlet determined that the best match -was `Get-Command` followed by other native commands on the system that were a -similar match. +In this example, the name of the command deliberately has a typo as 'get-commnd'. Using the +`-UseFuzzyMatching` switch, the cmdlet determined that the best match was `Get-Command` followed by +other native commands on the system that were a similar match. ```powershell Get-Command get-commnd -UseFuzzyMatching ``` ```Output -CommandType Name Version Source ------------ ---- ------- ------ -Cmdlet Get-Command 6.2.0.0 Microsoft.PowerShell.Core -Application getconf 0.0.0.0 /usr/bin/getconf -Application command 0.0.0.0 /usr/bin/command +CommandType Name Version Source +----------- ---- ------- ------ +Cmdlet Get-Command 6.2.0.0 Microsoft.PowerShell.Core +Application getconf 0.0.0.0 /usr/bin/getconf +Application command 0.0.0.0 /usr/bin/command ``` ## PARAMETERS @@ -324,10 +331,10 @@ Application command 0.0.0.0 /u Indicates that this cmdlet gets all commands, including commands of the same type that have the same name. By default, `Get-Command` gets only the commands that run when you type the command name. -For more information about the method that PowerShell uses to select the command to run when -multiple commands have the same name, see [about_Command_Precedence](About/about_Command_Precedence.md). -For information about module-qualified command names and running commands that do not run by default -because of a name conflict, see [about_Modules](About/about_Modules.md). +For more information about the order that PowerShell searches for commands, see +[about_Command_Precedence](About/about_Command_Precedence.md). For information about +module-qualified command names and running commands that don't run by default because of a name +conflict, see [about_Modules](About/about_Modules.md). This parameter was introduced in Windows PowerShell 3.0. @@ -347,15 +354,15 @@ Accept wildcard characters: False ### -ArgumentList -Specifies an array of arguments. This cmdlet gets information about a cmdlet or function when it is +Specifies an array of arguments. This cmdlet gets information about a cmdlet or function when it's used with the specified parameters ("arguments"). The alias for **ArgumentList** is **Args**. To detect dynamic parameters that are available only when certain other parameters are used, set the value of **ArgumentList** to the parameters that trigger the dynamic parameters. To detect the dynamic parameters that a provider adds to a cmdlet, set the value of the -**ArgumentList** parameter to a path in the provider drive, such as WSMan:, HKLM:, or Cert:. When -the command is a PowerShell provider cmdlet, enter only one path in each command. The provider +**ArgumentList** parameter to a path in the provider drive, such as `WSMan:`, `HKLM:`, or `Cert:`. +When the command is a PowerShell provider cmdlet, enter only one path in each command. The provider cmdlets return only the dynamic parameters for the first path the value of **ArgumentList**. For information about the provider cmdlets, see [about_Providers](About/about_Providers.md). @@ -384,18 +391,19 @@ The acceptable values for this parameter are: - `All`: Gets all command types. This parameter value is the equivalent of `Get-Command *`. -- `Application`: Gets non-PowerShell files in paths listed in the **Path** environment variable - (`$env:path`), including `.txt`, `.exe`, and `.dll` files. For more information about the **Path** - environment variable, see [about_Environment_Variables](About/about_Environment_Variables.md). +- `Application`: Searches folders in the `$env:PATH` environment variable for non-PowerShell + executable files. On Windows, executable files have a file extension that is listed in the + `$env:PATHEXT` environment variable. For more information, see + [about_Environment_Variables](About/about_Environment_Variables.md). - `Cmdlet`: Gets all cmdlets. - `ExternalScript`: Gets all `.ps1` files in the paths listed in the **Path** environment variable - (`$env:path`). + (`$env:PATH`). - `Filter` and `Function`: Gets all PowerShell advanced and simple functions and filters. -- `Script`: Gets all script blocks. To get PowerShell scripts (`.ps1 `files), use the +- `Script`: Gets all script blocks. To get PowerShell scripts (`.ps1` files), use the `ExternalScript` value. These values are defined as a flag-based enumeration. You can combine multiple values together to @@ -442,7 +450,7 @@ A module specification is a hashtable that has the following keys. - `RequiredVersion` - Specifies an exact, required version of the module. This can't be used with the other Version keys. -You cannot specify the **FullyQualifiedModule** parameter in the same command as a **Module** +You can't specify the **FullyQualifiedModule** parameter in the same command as a **Module** parameter. The two parameters are mutually exclusive. ```yaml @@ -677,7 +685,7 @@ Accept wildcard characters: False ### -UseFuzzyMatching Indicates using a fuzzy matching algorithm when finding commands. The order of the output is from -closest match to least likely match. Wildcards should not be used with fuzzy matching as it will +closest match to least likely match. Wildcards shouldn't be used with fuzzy matching as it will attempt to match commands that may contain those wildcard characters. ```yaml @@ -714,7 +722,8 @@ Accept wildcard characters: True This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](About/about_CommonParameters.md). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](About/about_CommonParameters.md). ## INPUTS @@ -726,7 +735,7 @@ You can pipe command names to this cmdlet. ### System.Management.Automation.CommandInfo -This cmdlet returns objects derived from the **CommandInfo** class. The type of object that is +This cmdlet returns objects derived from the **CommandInfo** class. The type of object that's returned depends on the type of command that `Get-Command` gets. ### System.Management.Automation.AliasInfo