TLDRBins TLDRBins / Monitor Process (Windows)


Usage Tips:

  • Click on a keyword to enable inline editing.
  • Click inside a code block to copy (excludes comments).
  • Use the button to view examples.
  • Click outside to collapse all examples.

Template

# Define the process name $processName = "<PROCESS>" # Define the interval in seconds between checks (e.g., 5 seconds) $interval = 5 # Start an infinite loop while ($true) { # Check if the process is running $process = Get-Process -Name $processName -ErrorAction SilentlyContinue if ($process) { # If the process is found, perform your action Write-Host "<PROCESS> process is running." # Perform your custom action here # Example: Write-Host "Performing action..." } else { # If the process is not found, output a message Write-Host "<PROCESS> process is not running." } # Wait for the defined interval before checking again Start-Sleep -Seconds $interval }
Sample Output: TO-DO

Execution

# Bypass script execution policy powerShell.exe -ExecutionPolicy UnRestricted -File monitor.ps1
Sample Output: TO-DO