Interpreting the PowerShell Syntax

Interpreting the PowerShell Syntax

This beginner-friendly resource helps you develop some understanding about how to interpret PowerShell commands.

Here are some of the most commonly used parameters:

help Get-Service              # Display basic help information about this cmdlet
help Get-Service -Full        # Display full help
help Get-Service -Detailed    # Display detailed help
help Get-Service -Examples    # Display examples
help Get-Service -ShowWindow  # Display in a seperate window
help Get-Service -Online      # Display help online

Update help:

Update-Help -Force -ErrorAction SilentlyContinue

Understanding syntax!

When we read the PowerShell help pages, we have a few syntax depending on the command. That said, you are only required to use one of them depending on the situation at hand.

Untitled.png

  • [ [-Name] <String[]> ] → Parameters in square brackets are optional
  • [[-Name]<String[]> ] → Supplying the parameter name (-Name) is optional as long as you are supplying the values at the right position.
  • [[-Name]<String[]> ]String[] indicates it needs one or more values (array).

Untitled 1.png

  • [-DependentServices] → It's called switch parameter (on/off). It doesn't take any additional parameters.
  • [-DependentServices] → Optional (Square brackets)

Untitled 2.png

  • [-ComputerName <String[]>] → Optional parameter because it is in square brackets.
  • [-ComputerName <String[]>] → When you want to give the computer name, you should know that -ComputerName is a named parameter. So you must supply the parameter name when giving the values.
  • [-ComputerName <String[]>]String[] indicates it needs one or more values (array).

Hope it helps!

P.S: Please don't hesitate to share your constructive comments as I am also a PowerShell learner.

P.S: I am planning to create more beginner-friendly resources on PowerShell & Bash. So for latest updates, feel free to follow me: