Basic Powershell Commands

PowerShell is built on .Net framework. It uses common language run-time and this framework accepts and returns .NET framework objects.

It consists of several commands; you can use to perform desired function.

PowerShell commands are in verb-noun format. Common verbs are:

Get - To get something like get system date

Start - To run something like start any process/program

Stop - To stop something that is running like any process/program

Set - To define something like 

Here we will cover basic commands. First let’s check PowerShell version running on machine.

Run Powershell

Enter $PSVersionTable

How would I know what different commands are available in PowerShell?

You can use Get-Command, It will return all cmdlets and functions that can be invoked/executed on machine.

Is there any way to filter these commands as it returned lot of commands?

Yes. You can use words with wildcards like below:

Get-Command *process*


Get-Help Start-Process

Will return information on how you can use Start-Process. Similarly you can use Get-Help with any command to get info about that.


When you run Get-Help first time it will ask you to run Update-Help. If you press

Y, it will download and install help files.

N, It will only display partial help. 

You can also view help topics for commands online.

Get-Help Start-Process -Online

This will open help info related to command in browser. 


Few examples of Start-Process are below:

Start-Process -FilePath “notepad”

Will open notepad.

Start-Process -FilePath “calc”

Will open calculator.

How to stop running process?

Below command can be used to stop running process, process name required as parameter.

Stop-Process -Name "notepad"



Comments

Popular Posts

How to Import and Export Delimited Files, like CSV, in PowerShell

PowerShell Arithmetic Operators

How to generate a GUID in PowerShell