Getting Started with PowerShell Commands which Every Devops should Know.

PowerShell is a strong tool which contains rich command utilities and commands which can make life easier for developers and Devops engineers. In this tutorial we will learn about important commands which are run on PowerShell with all practical’s to get you started with it.

Table of Content

  1. What is PowerShell ?
  2. Prerequisites
  3. Getting Started with PowerShell commands
  4. Wrapping Up

What is PowerShell ?

PowerShell is a command line tool or command line shell which helps in automation of various tasks , allows you to run scripts & helps you in managing variety of configuration. PowerShell runs on Windows , Linux and macOS

PowerShell is built on .NET Command Language Runtime that is ( CLR ) . It works currently on .NET 5.0 Framework as its runtime.

Features of PowerShell

  • It provides tab completion
  • It works with all .NET Frameworks objects
  • It allows pipelines of commands.
  • It has built support for various file formats such as JSON, CSV and XML

Prerequisites

Getting Started with PowerShell commands

PowerShell is a command line shell or command line tool or command line utility. There are tons of commands which are already loaded or in built in PowerShell and these commands are known as cmdlets.

  • There are majorly three types of command type in PowerShell
    • Alias
    • cmdlets
    • Function
  • To check the current version of PowerShell
$PSVersionTable
  • To check the execution policy of PowerShell
    • Restricted indicates that users are not allowed to run the scripts unless restrictions are removed.
Get-ExecutionPolicy
  • To Update the execution policy of PowerShell
    • This policy will allow users to run the Scripts
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned    # Run as Administrator
  • To Check all the commands on PowerShell
Get-Command
  • To get help with command execution and about the command on Powershell
Get-Help
  • To check the status of Windows32 time service
Get-Service -Name w32time
  • To check the short form of PowerShell commands use Alias.
Get-Alias -Name gcm
Get-Alias -Name gm
  • To check the Folder structure and files under the folder.
 Get-ChildItem -Path C:\
  • To open system logs using PowerShell command
Show-EventLog
  • To check specific details of process such as chrome browser
 Get-Process chrome
  • To get content of a particular file
Get-Content .\.gitignore
  • To get drives in the current session
Get-PSDrive
  • To remove a particular file or folder using the following command.
Remove-Item .\date.txt

Wrapping up

This was pretty straightforward tutorial which covers basic PowerShell commands. We learnt majorly GET-command, GET-service command and different cmdlets which can be used with PowerShell. Hope this was useful tutorial to get you started with how to run commands on PowerShell.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s