|
2 | 2 | external help file: System.Management.Automation.dll-Help.xml |
3 | 3 | Locale: en-US |
4 | 4 | Module Name: Microsoft.PowerShell.Core |
5 | | -ms.date: 11/09/2024 |
| 5 | +ms.date: 08/19/2025 |
6 | 6 | online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/get-command?view=powershell-5.1&WT.mc_id=ps-gethelp |
7 | 7 | schema: 2.0.0 |
| 8 | +aliases: |
| 9 | + - gcm |
8 | 10 | title: Get-Command |
9 | 11 | --- |
10 | 12 | # Get-Command |
@@ -37,8 +39,8 @@ Get-Command [[-Name] <string[]>] [[-ArgumentList] <Object[]>] [-Module <string[] |
37 | 39 |
|
38 | 40 | The `Get-Command` cmdlet gets all commands that are installed on the computer, including cmdlets, |
39 | 41 | aliases, functions, filters, scripts, and applications. `Get-Command` gets the commands from |
40 | | -PowerShell modules and commands that were imported from other sessions. To get only commands that |
41 | | -have been imported into the current session, use the **ListImported** parameter. |
| 42 | +PowerShell modules and commands available on your system. To get only commands that have been |
| 43 | +imported into the current session, use the **ListImported** parameter. |
42 | 44 |
|
43 | 45 | Without parameters, `Get-Command` gets all the cmdlets, functions, and aliases installed on the |
44 | 46 | computer. `Get-Command *` gets all types of commands, including all the non-PowerShell files in the |
@@ -789,15 +791,22 @@ PowerShell includes the following aliases for `Get-Command`: |
789 | 791 | - All platforms: |
790 | 792 | - `gcm` |
791 | 793 |
|
792 | | -- When more than one command that has the same name is available to the session, `Get-Command` |
793 | | - returns the command that runs when you type the command name. To get commands that have the same |
794 | | - name, listed in run order, use the **All** parameter. For more information, see |
795 | | - [about_Command_Precedence](../Microsoft.PowerShell.Core/About/about_Command_Precedence.md). |
796 | | -- When a module is imported automatically, the effect is the same as using the `Import-Module` |
797 | | - cmdlet. The module can add commands, types and formatting files, and run scripts in the session. |
798 | | - To enable, disable, and configuration automatic importing of modules, use the |
799 | | - `$PSModuleAutoLoadingPreference` preference variable. For more information, see |
800 | | - [about_Preference_Variables](../Microsoft.PowerShell.Core/About/about_Preference_Variables.md). |
| 794 | +When more than one command that has the same name is available to the session, `Get-Command` returns |
| 795 | +the command that runs when you type the command name. To get commands that have the same name, |
| 796 | +listed in run order, use the **All** parameter. For more information, see |
| 797 | +[about_Command_Precedence](About/about_Command_Precedence.md). |
| 798 | + |
| 799 | +If you run `Get-Command` with the exact name of the command, without wildcard characters, PowerShell |
| 800 | +searches for the command in all available modules. If the module containing the command isn't loaded |
| 801 | +yet, the result returned by `Get-Command` only contains information that can be discovered from the |
| 802 | +module manifest. For example, the **ScriptBlock** property might not be populated in the initial |
| 803 | +result. However, PowerShell automatically imports the module after it returns the initial result. |
| 804 | + |
| 805 | +When a module is imported automatically, the effect is the same as using the `Import-Module` cmdlet. |
| 806 | +The module can add commands, types and formatting files, and run scripts in the session. To enable, |
| 807 | +disable, and configuration automatic importing of modules, use the `$PSModuleAutoLoadingPreference` |
| 808 | +preference variable. For more information, see |
| 809 | +[about_Preference_Variables](About/about_Preference_Variables.md). |
801 | 810 |
|
802 | 811 | ## RELATED LINKS |
803 | 812 |
|
|
0 commit comments