Powershell — 3 Cmdlets Hackerrank Solution

$aliceScore = 0 $bobScore = 0 0..2 | ForEach-Object if ($a[$] -gt $b[$]) $aliceScore++ elseif ($b[$] -gt $a[$]) $bobScore++

Write-Output "$aliceScore $bobScore"

Cmdlets used: -split, ForEach-Object, Write-Output. powershell 3 cmdlets hackerrank solution


Get-Process |
    Where-Object  $_.CPU -gt 10  |
    Sort-Object CPU -Descending |
    Select-Object ProcessName, CPU, Id |
    Format-Table -AutoSize

Filters objects based on a condition.

$data | Where-Object  $_.YearsOfExperience -ge 2