Windows PowerShell is designed to be an interactive command-line shell and it’s also a programming language. A PowerShell script is really nothing more than a simple text file. The file contains a series of PowerShell commands, with each command appearing on a separate line.

If we need to run the PowerShell script using the notepad then its filename needs to save as .PS1 extension.

Powershell Variables

Is It Case Sensitive

The answer is “YES”, power shell comments are case sensitive. 

  • As like other programming language, we need to declare the variable as like below. The main difference is we need to add prefix with ‘$’ symbol in the variable.
  • All we have to do to declare those variables is add a dollar sign, then use whatever name for the variable we want and no spaces are allowed in the variable name.

Example : 1

Example : 2

Example : 3 Handling Dynamic Variables.

The Get-Variable cmdlet gets the PowerShell variables in the current console. You can retrieve just the values of the variables by specifying the ValueOnly parameter.

OUTPUT: This is specific MSG for Anna