Forum Discussion

jozsef_sarosi's avatar
jozsef_sarosi
GoTo Contributor
4 months ago

How to execute PS1 files as Rescue Scripts (template)

The execution of  Rescue scripts needs some special knowledge from the script writers, especially when the applet side script or binary is not a directly executable code.
Such are PowerShell scripts, those cannot be directly started from command shell. Earlier scripts with extension PS1 could be started, but not now.

I have created a template that consists of two components,  a starter scrip (CMD) and a PowerShell Script (PS1) as a resource. The template is also an example for
- delaying the clean up of the applet, until the PS1 script really ends
- logging for the command, and collecting the logs for the log shown in the TC
- break out from the hidden-no UI state of scrips preferred by the applet.

  • To execute PS1 files as Rescue Scripts: Create a Starter CMD Script: Use a CMD script to invoke the PowerShell script, ensuring it waits for completion and handles logging. Run PowerShell Script: Call the PS1 file from the CMD script using powershell -ExecutionPolicy Bypass -File "path\to\script.ps1". Manage Cleanup and Logs: Ensure the CMD script manages cleanup after the PS1 script finishes and collects logs for review.

  • To execute PS1 files (PowerShell scripts) as rescue scripts:

    1. Open PowerShell: Run PowerShell with administrative privileges.
    2. Set Execution Policy: Use the command Set-ExecutionPolicy RemoteSigned or Set-ExecutionPolicy Bypass to allow script execution.
    3. Run the Script: Navigate to the script's directory and execute it using .\scriptname.ps1.

    Replace scriptname.ps1 with your actual file name.