Power of Powershell — Introduction for Testers

Suman Tomer
2 min readApr 18, 2022

What is Power-Shell?

PowerShell is a cross-platform task automation solution made up of a command-line shell, a scripting language, and a configuration management framework.
PowerShell runs on Windows, Linux, and macOS.

Download Power-Shell for Windows.
https://github.com/PowerShell/PowerShell/releases/download/v7.2.2/PowerShell-7.2.2-win-x64.msi

Once, MSI package is downloaded, Right click on the file and click properties and unlock it as shown below.

Unblock the MSI package.

Install the MSI and follow the install steps.

Search for Power-Shell and open it its CLI locally.

Open PowerShell CLI
PowerShell CLI

Now play with the following PowerShell commands

Get-Command will list you the commands you can execute on your system. If you expect a command which is not listed you must install the PowerShell package to install and enable it on the system.

Get-Command
Get-Help
Get-ExecutionPolicy
Set-ExecutionPolicy -ExecutionPolicy Restricted -Scope LocalMachine
Get-Service
Get-Service | Where-Object {$_.status -eq "stopped"}
get-alias | convertto-html > aliases.htm
invoke-item aliases.htm
Get-Process | Export-Csv -Path .\Processes.csv -NoTypeInformation
Get-Content -Path .\Processes.csv
Get-EventLog -Log "Application"Get-ProcessStop-Process -processname notepadhistoryClear-History -Command *Get-ExecutionPolicy*Get-Service | Where-Object {$_.Status -eq 'Running'}

Create a string loop in PowerShell.

$employees = @("Bob","Ram","John","Lakshmi")
for ($i=0; $i -lt $employees.Length; $i++)
{ if ($employees[$i] -eq "Ram") { write-host "Boss $($employees[$i])" } else { write-host "Employee $($employees[$i])" }};

You can follow more commands to get familiar with PowerShell

https://devblogs.microsoft.com/scripting/table-of-basic-powershell-commands/
https://stackify.com/powershell-commands-every-developer-should-know/

--

--

Suman Tomer

Test Automation, QA Engineer, Azure Cloud, Helping woman who wants to learn testing and join industries