Get-Process | Where-Object {$_.Name -like "idea*"}
 Get-Process | Where-Object {$_.Name -like "idea*"} | Format-Table
 Get-Process | Where-Object {$_.Name -like "idea*"} | ConvertTo-Json
 
 # Format to JSON
 Get-Process | ConvertTo-Json
 
 # can use JQ as well:
 Get-Process | ConvertTo-Json | jq -c

Hello World

On linux to create file that will execute by powershell:

#!/usr/bin/env pwsh
 
Write-Host "Hello from PowerShell!"
Link to original

Call Bash in Parallel from Powershell

#!/usr/bin/env pwsh
 
Write-Host "Hello from PowerShell!"
 
1..2 | ForEach-Object -Parallel {
    bash /Users/nkondrat/vintrin-env/.tmp/scratches/scratch.sh $_ ABC
} -ThrottleLimit 1000
Link to original

Error Handling Non Zero Return Codes

#!/usr/bin/env pwsh
 
# Can make any non zero exit codes be treated as proper termination errors
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
 
function Main {
    param($arg1, $arg2)
 
    Write-Host "Starting script..."
 
    try {
        # Can invoke bash scripts,
        & $env:ISSH
        Write-Host "Command succeeded"
    }
    catch {
        # If bash scripts fail we can have a proper catch block
        Write-Host "CAUGHT ERROR: $($_.Exception.Message)"
    }
 
    Write-Host "Script completed."
}
 
# Invoke it at the end
Main -arg1 "value1" -arg2 "value2"
Link to original