PowerShell Script
PowerShell Script (.ps1)
Allows you to execute a PowerShell (.ps1) script in a Windows environment.
Code
The code of the PowerShell script to execute. Variables can be used in this script and will be replaced before executing
# This is a template PowerShell script
# Replace {file.FullName} and {file.Orig.FullName} with actual values
$WorkingFile = '{file.FullName}'
$OriginalFile = '{file.Orig.FullName}'
# Example commands using the variables
Write-Output "Working on file: $WorkingFile"
Write-Output "Original file location: $OriginalFile"
# Add your actual PowerShell commands below
# Example: Copy the working file to a backup location
# Copy-Item -Path $WorkingFile -Destination "C:\Backup\$([System.IO.Path]::GetFileName($WorkingFile))"
# Set the exit code to 1
exit 1
Exit Codes
Number | Description |
---|---|
1+ | Specifies which output is to be called. Define the number of outputs using the Outputs field. This will add more output connections to the flow element. |
0 | Completes the flow successfully. This will immediately stop the flow and mark it as successful. |
other | If a number is returned that is outside the range of defined outputs, this will mark the flow as unsuccessful. |
Examples
Steam Gaming Running
This script will test if steam is running and if there is a child-process. Its not a fool proof way of detecting if a game is running, but its a start
# Define the Steam process name and pattern to identify Steam-related processes
$steamProcessName = "steam"
$steamGameProcessPattern = "*steam*"
# Get the list of running processes
$runningProcesses = Get-Process
# Check if Steam is running
$steamRunning = $runningProcesses | Where-Object { $_.Name -eq $steamProcessName }
if ($steamRunning -eq $false) {
Write-Output "Steam is not running."
exit 1 # Exit with code 1 if Steam is not running
}
# List all running processes that are likely Steam games
$steamGameProcesses = $runningProcesses | Where-Object { $_.Path -like $steamGameProcessPattern }
if ($steamGameProcesses.Count -gt 0) {
Write-Output "Steam is running and the following Steam-related processes (likely games) are currently running:"
$steamGameProcesses | ForEach-Object { Write-Output $_.Name }
exit 0 # Exit with code 0 if Steam games are running
} else {
Write-Output "Steam is running, but no associated processes (likely games) are found."
exit 1 # Exit with code 1 if no Steam games are running
}