Powershell beginner commands

Nuthan Murarysetty
2 min readJun 13, 2021

--

Important points before you start knowing and practice these Powershell commands.

  1. Powershell commands are case-insensitive but filenames are case-sensitive
  2. You will remember these commands only when you type not copy the commands.
  3. Powershell file extension: “.ps1”
  4. Commenting any line in PowerShell is with #(pound) symbol.
  5. Variables defined using $(dollar) symbol along with the name of your variable. Ex: $name
  6. Strings we can write either using the ‘ single coded string ’ or “ double coded string“
  7. In general, Computer does not understand our high-level commands for many programming languages uses compilers and interpreters to compile high level to a computer that understands the format. In Powershell, have a similar but first it stores/checks in AST (Abstract Syntax Tree) — Stores in memory and then runs. Before the computer runs first Powershell checks here and if everything is good then the computer runs.
  8. An important command is Get-Help -Name “<Nameofyourcommand”> -Full => You will know detailed information about the command. Ex: Write-Output

Command 1: To create a new file

New-Item <fileName>.ps1

Command 2: To add script inside the file

code <fileName>.ps1

Note: As in this example it opens VS Code

Statement: To write output in the console window

Write-Output “<String what you want>”

Refer to the above screenshot.

Command 3: To run the Powershell file

.\<FileName>.ps1

To comment on any text in PowerShell file

# Write-Output “Hello”

Statement: Read the input from the user

$name = Read-Host -Prompt “Please enter your name”

Write-Output “Hello $name! “

To know detailed information about any cmdlet

Get-Help -Name “Write-Output” -Full

It’s your time to start Powershell. I will come up with few more important commands and keep practising.

-Happy Reading :)

--

--

Nuthan Murarysetty
Nuthan Murarysetty

Written by Nuthan Murarysetty

I love sharing things what I know to others and passionate in photography.

No responses yet