Powershell-Language



First PS1 file

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.
For the text file to be treated as a PowerShell script, its filename needs to use the .PS1 extension.

  • Step 1 :- Create a simple text file.
  • Step 2 :- Write any powershell commands
    E.g. Get-Process | Sort-Object ID
    Note : Get-Process using this you can get a list of processes by using the Get-Process cmdlet, "Sort-Object ID" for the list will be sorted by ID. Use pipe symbol for seperation "|"
  • Step 3 :- Rename extension .txt to .PS1 extension (Create at some location with FirstPowershell.PS1 e.g. C:\PowershellScripts\)
  • Step 4 :- Open powershell and Run C:\PowershellScripts\FirstPowershell.PS1

Powershell Variables
If you want to use the variable, simply call it by name and prefix with '$' symbol.
$firstVarible = "This is a test" (Assign text to varible)
$firstVarible (Print varible value output should be "This is a test")
$firstVarible = $firstVarible + " Added text"
$firstVarible (Print varible value output should be "This is a test Added text")

Windows PowerShell includes its own extensive, console-based help