PowerShell Help | Get-Help
Probably the most important PowerShell command is Get-Help. With Get-Help the integrated PowerShell help can be called, it gives an overview of the function of the individual commands and their application, up to concrete examples.
When the help function(Get-Help
) is started for the first time, it is reloaded from the Internet via the command Update-Help
. (Since version 3.0 the help is no longer part of the operating system).
Update-help downloads all necessary help files if the Internet is available:
Help for a specific command
Get-Help CommandName.
As command I use in the following examples the command Get-Command
. Get-Command
lists all available commands and can be used when searching for a specific command. So if you don't know the name of a command, you can use Get-Command
to find it and then Get-Help
to get help.
To get help for the command Get-Command
as an example, this can be done using
get-help get-command
or simply with
get-command -?
As an example of how to display help for the get-command
command:
C:\> get-help get-command
NAME
Get-Command
ÜBERSICHT
Gets all commands.
SYNTAX
Get-Command [[-Name] <System.String[]>] [[-ArgumentList] <System.Object[]>] [-All] [-CommandType {Alias | Function
| Filter | Cmdlet | ExternalScript | Application | Script | Workflow | Configuration | All}]
[-FullyQualifiedModule <Microsoft.PowerShell.Commands.ModuleSpecification[]>] [-ListImported] [-Module
<System.String[]>] [-ParameterName <System.String[]>] [-ParameterType <System.Management.Automation.PSTypeName[]>]
[-ShowCommandInfo] [-Syntax] [-TotalCount <System.Int32>] [<CommonParameters>]
Get-Command [[-ArgumentList] <System.Object[]>] [-All] [-FullyQualifiedModule
<Microsoft.PowerShell.Commands.ModuleSpecification[]>] [-ListImported] [-Module <System.String[]>] [-Noun
<System.String[]>] [-ParameterName <System.String[]>] [-ParameterType <System.Management.Automation.PSTypeName[]>]
[-ShowCommandInfo] [-Syntax] [-TotalCount <System.Int32>] [-Verb <System.String[]>] [<CommonParameters>]
BESCHREIBUNG
The `Get-Command` cmdlet gets all commands that are installed on the computer, including cmdlets, aliases,
functions, filters, scripts, and applications. `Get-Command` gets the commands from 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.
`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).
`Get-Command` gets its data directly from the command code, unlike `Get-Help`, which gets its information from
help topics.
Starting in Windows PowerShell 5.0, results of the `Get-Command` cmdlet display a Version column by default. A new
Version property has been added to the CommandInfo class.
VERWANDTE LINKS
Online Version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/get-command?view=powershell-
5.1&WT.mc_id=ps-gethelp
Export-PSSession
Get-Help
Get-Member
Get-PSDrive
Import-PSSession
about_Command_Precedence
HINWEISE
Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Get-Command -examples".
Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Get-Command -detailed".
Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Get-Command -full".
Geben Sie zum Abrufen der Onlinehilfe Folgendes ein: "get-help Get-Command -online"
Help Examples
Examples for a command can be displayed with get-help command -examples
, here again as an example our command get-command
PS P:\> get-help get-command -examples
NAME
Get-Command
ÜBERSICHT
Gets all commands.
-------- Example 1: Get cmdlets, functions, and aliases --------
Get-Command
-------- Example 2: Get commands in the current session --------
Get-Command -ListImported
------- Example 3: Get cmdlets and display them in order -------
Get-Command -Type Cmdlet | Sort-Object -Property Noun | Format-Table -GroupBy Noun
------------- Example 4: Get commands in a module -------------
Get-Command -Module Microsoft.PowerShell.Security, Microsoft.PowerShell.Utility
---------- Example 5: Get information about a cmdlet ----------
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).
------------ Example 6: Get the syntax of a cmdlet ------------
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.
For more information about the Certificate provider, see about_Certificate_Provider
(../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md).
-------------- Example 7: Get dynamic parameters --------------
function Get-DynamicParameters
{
param ($Cmdlet, $PSDrive)
(Get-Command -Name $Cmdlet -ArgumentList $PSDrive).ParameterSets |
ForEach-Object {$_.Parameters} |
Where-Object { $_.IsDynamic } |
Select-Object -Property Name -Unique
}
Get-DynamicParameters -Cmdlet Get-ChildItem -PSDrive Cert:
Name
----
CodeSigningCert
The `Get-DynamicParameters` function in this example gets the dynamic parameters of a cmdlet. This is an
alternative to the method used in the previous example. Dynamic parameter can be added to a cmdlet by another
cmdlet or a provider.
----------- Example 8: Get all commands of all types -----------
Get-Command *
It returns an ApplicationInfo object (System.Management.Automation.ApplicationInfo) for each file, not a FileInfo
object (System.IO.FileInfo).
-- Example 9: Get cmdlets by using a parameter name and type --
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 authenticate
the user.
The ParameterType parameter distinguishes parameters that take an AuthenticationMechanism value from those that
take an AuthenticationLevel parameter, even when they have similar names.
------------------- Example 10: Get an alias -------------------
Get-Command -Name dir
CommandType Name ModuleName
----------- ---- ----------
Alias dir -> Get-ChildItem
Although it is 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 view shows the alias
and the full command name.
----- Example 11: Get all instances of the Notepad command -----
Get-Command Notepad -All | Format-Table CommandType, Name, Definition
CommandType Name Definition
----------- ---- ----------
Application notepad.exe C:\WINDOWS\system32\notepad.exe
Application NOTEPAD.EXE C:\WINDOWS\NOTEPAD.EXE
The All parameter is useful when there is more than one command with the same name in the session.
Beginning in Windows PowerShell 3.0, by default, when the session includes multiple commands with the same name,
`Get-Command` gets only the command that runs when you type the command name. With the All parameter,
`Get-Command` gets all commands with the specified name and returns them in 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).
- Example 12: Get the name of a module that contains a cmdlet -
(Get-Command Get-Date).ModuleName
Microsoft.PowerShell.Utility
This command format works on commands in PowerShell modules, even if they are not imported into the session.
Example 13: Get cmdlets and functions that have an output type
Get-Command -Type Cmdlet | Where-Object OutputType | Format-List -Property Name, OutputType
This command gets the cmdlets and functions that have an output type and the type of objects that they return.
The first part of the command gets all cmdlets. A pipeline operator (`|`) sends the cmdlets to the `Where-Object`
cmdlet, which selects only the ones in which the OutputType property is populated. Another pipeline operator sends
the selected cmdlet objects to the `Format-List` cmdlet, which displays the name and output type of each cmdlet in
a list.
The OutputType property of a CommandInfo object has a non-null value only when the cmdlet code defines the
OutputType attribute for the cmdlet.
Example 14: Get cmdlets that take a specific object type as input
Get-Command -ParameterType (((Get-NetAdapter)[0]).PSTypeNames)
CommandType Name ModuleName
----------- ---- ----------
Function Disable-NetAdapter NetAdapter
Function Enable-NetAdapter NetAdapter
Function Rename-NetAdapter NetAdapter
Function Restart-NetAdapter NetAdapter
Function Set-NetAdapter NetAdapter
This command finds cmdlets that take net adapter objects as input. You can use this command format to find the
cmdlets that accept the type of objects that any command returns.
The command uses the PSTypeNames intrinsic property of all objects, which gets the types that describe the object.
To get the PSTypeNames property of a net adapter, and not the PSTypeNames property of a collection of net
adapters, the command uses array notation to get the first net adapter that the cmdlet returns. To get the
PSTypeNames property of a net adapter, and not the PSTypeNames property of a collection of net adapters, the
command uses array notation to get the first net adapter that the cmdlet returns.
Update Help without Internet Connection
To install the PowerShell help on a computer without Internet, it can be exported in advance on an Internet-enabled device and then imported to the Pc without Internet:
Export Help:
PS C:\> Save-Help -DestinationPath c:\pshelp -Module * -Force -UICulture "en-us"
Importing the help on a destination computer without Internet:
PS C:\Windows\system32> update-help -SourcePath c:\pshelp -Module * -force
PowerShell help in a self created cmdlet
{{percentage}} % positive