Introduction to windows powershell

Windows power shell is the advanced version of shell for Windows Operating system. It is just like Linux Shell like BASH.Key features of Windows Powershell are given below.
  • introduced with Windows 7
  • super set of Windows Command Prompt
  • based on .Net Framework
  • COM and WMI automation
  • Cross-Platform
  • Open Source
  • WS (Web Service) Management and CIM (Common Information Model)

Getting help

To get help on everything, you can execute below command.
> get-help *

Above command displays help terms from various categories like alias, Cmdlet, function, HelpFile. To get the help on all command lets
get-help -Category cmdlet

To get the help on all functions get-help -Category function
get-help -Category provider

To get the help on all Help Files
get-help -Category helpfile

We can also use below command (Alias – gcm) to show the list of commands and functions.
> Get-Command
To display commands with specific name say xyz
> Get-Command *xyz*

“Get-Command” also allows you to search the commands using nouns or verbs.
> Get-Command -noun Job

To get examples and full information about specific command, you can use below syntax.
get-help <command-name> -online
get-help <command-name> -full
get-help <command-name> -examples

To update the help, you can use below command.
> update-help

To get the list of all verbs, you can use below command.
> Get-Verb

Understanding command syntax

“Get-Help” command shows the syntax of command. Looking at the syntax, we can figure out what parameters are positional, optional etc. It also shows the aliases for the command. As you can see in above image, there are many variations of Get-Process command. Anything in the [] is optional. string[] means that parameter takes array of strings. Also note that in the end it is saying [commonParameters]. Usually all commands can accept common parameters. Here is the list of common parameters.
  • verbose
  • debug
  • WarningAction
  • ErrorAction
  • ErrorVariable
To clear the screen, you can use “clear” command (Just like in Linux). You should also know some of the Powershell extensions.
  • .ps1 – Powershell script file
  • .psd1 – data file
  • .psm1 – Powershell Script module
Tips and tricks You do not need to type complete command at the command prompt. You just need to type first few characters and Powershell completes it for you. For example instead of typing “Get-Process”, you can type “Get-Pro” only and then press TAB key. Same applies to the parameters of the command as well
Complex problems, Simple Solutions