Help System
To get proper help easily is essential skill in PowerShell. PowerShell has lot of info for all commands etc.
Three Core Cmdlets
- Get-Help
- Get-Command
- Get-Member
Get-Help
The Get-Help
cmdlet displays information about PowerShell concepts and commands, including cmdlets, functions, Common Information Model (CIM) commands, workflows, providers, aliases, and scripts.
To get help for a PowerShell cmdlet, type Get-Help
followed by the cmdlet name, such as: Get-Help Get-Process
.
Get-Command
Get-Command
shows all commands. The list is very long because Get-Command -cmdlet gets all commands that are installed on the computer, including cmdlets, aliases, functions, filters, scripts, and applications.
If you want to get only list some of command, you can specify command type
like this:
Get-Command -CommandType Alias
Get-Command with wildcard
If you know that you should find command that contains special characters, you can use asterisk * as a wild card.
Get-Command Get-Di*
Get-Member
PowerShell always works with objects
. Like in generally in programming, also PowerShell objects have two kind of members
: properties
and methods
. Because all Powershell commands return objects, we can get objects members with command Get-Member
Get-LocalUser | Get-Member
Aliases
An alias
in PowerShell is a another shorter name for a command. PowerShell includes built-in aliases. You can also define your own aliases.
The Get-Alias cmdlet is used to find aliases. If you already know the alias for a command, the Name parameter is used to determine what command the alias is associated with.
Get-Alias
Some common aliases
Alias | Command |
---|---|
Foreach, % | Foreach-Object |
Sort | Sort-Object |
Where,? | Where-Object |
Cd,chdir,sl | Set-Location |
Dir,ls,gci | Get-ChildItem |
Del,rm | Remove-Item |
Pwd | Get-Location |
Briefly
Command | Description |
---|---|
Get-Command | Get all commands |
Get-Command -Module AppLocker | Get all commands in AppLocker module |
Get-Command Get-p* | Get all commands starting with get-p |
Get-Help Get-Process | Get help for command Get-Process |
Get-Member | Get members of the object |