Skip to content

Commands

  • Command: The action (e.g., Get-Service).
  • Parameter: Starts with a hyphen (Name).
  • Switch: A parameter without a value; it’s just “On” or “Off.”

  • Get-Command: Lists every available command (scripts, aliases, functions).
  • Get-Help: Shows instructions and syntax diagrams.
    • [ ] = Optional parameter.

    • < > = Optional Value to Parameter, Data type required (e.g., <String>).

      image.png


  • Cmdlet: A built-in, lightweight PowerShell command.
  • Function: A custom, named block of code.
  • Alias: A nickname or shortcut for a command (e.g., dir for Get-ChildItem).

Commands have “modes.” You cannot mix parameters from different sets.

  • Example: You can find a process by Name OR by Id, but usually not both at once.

If names conflict, PowerShell runs them in this order:

  1. Alias (Winner)
  2. Function
  3. Cmdlet
  4. Windows Native Apps (.exe)

image.png

Use this when you know what you want to do but don’t know the exact command name. It searches the “toolbox.”

  • Example: Find all commands related to “Service” PowerShell

    Get-Command *Service*

  • Example: Find all commands that start with the verb “Restart” PowerShell

    Get-Command -Verb Restart

    image.png

    image.png


Use this once you have the command name but need to know the syntax, parameters, or see examples.

  • Example: See the basic syntax of Get-ProcessPowerShell

    Get-Help Get-Process

  • Example: See real-world usage examples for a commandPowerShell

    Get-Help Get-Content -Examples

  • Example: Open the full online documentation in your browserPowerShell

    Get-Help Stop-Service -Online

    image.png

    image.png

image.png

image.png