PowerShell - Practical Commands



 

 1. get-process | select-object ProcessName | Sort-Object ProcessName




2. get-process | where {$_.ProcessName -eq "systemd"} //comparison operator

3. $var = get-process | where {$_.ProcessName -eq "systemd"} // no need to type same command everytime then use variable to store the result and assign into code.

in powershell - everything is an object

$myVar = "Hello Cloud SME"
Set-Variable -Name $myVar -Description " Azure AWS GCP" select everything from that object.


Logical Commands

Add logic branch and looping to perform continue action until it finish the task.

1. Check Cpu is higher than 10  then print is high load

if($myVar.Cpu -gt 20)  {Write-Host " Cpu Load is High") 










Top 5 processor using cpu 




























Comments

Popular posts from this blog

Command into Scripts

Powershell Modules