Powershell>command_or_script,async,output,exit_code,error
Executes the specified Powershell command or script.
command_or_script: the command or script to execute
async: 0 = wait and return output, 1 = asynchronous - do not wait
output: variable to store output of script in
exit_code: the exit code
error: if an error occured will hold the error message.
Example
PowerShell>dir c:\,0,dirOutput,exitCode,err
MessageModal>dirOutput
Example
LabelToVar>script1,pScript
Powershell>pScript,0,theResult,exitCode,err
MessageModal>theResult
Powershell>dir c:\,0,dres,ec,err
MessageModal>dres
/*
script1:
# Example PowerShell Script: List top CPU-consuming processes
# This script retrieves running processes, sorts them by CPU usage,
# and exports the results to a CSV file.
try {
# Get all processes and sort by CPU usage (descending)
$processes = Get-Process | Sort-Object CPU -Descending
# Display top 10 processes in the console
Write-Host "Top 10 CPU-consuming processes:" -ForegroundColor Cyan
$processes | Select-Object -First 10 Name, CPU, Id | Format-Table -AutoSize
# Export all process data to a CSV file
$outputPath = "$PSScriptRoot\ProcessReport.csv"
$processes | Select-Object Name, CPU, Id, StartTime -ErrorAction SilentlyContinue |
Export-Csv -Path $outputPath -NoTypeInformation
Write-Host "Process report saved to: $outputPath" -ForegroundColor Green
}
catch {
Write-Host "An error occurred: $($_.Exception.Message)" -ForegroundColor Red
}
*/