Forum Discussion

jozsef_sarosi's avatar
jozsef_sarosi
GoTo Contributor
6 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.

3 Replies

  • 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.

     
     
     
     
     
     
  • jozsef_sarosi's avatar
    jozsef_sarosi
    GoTo Contributor
    6 months ago

    You are right, you can execute the PS1 script in PowerShell, too. 
    My goal was to publish a Rescue script that can be added to the set of scripts of a Technician Console.
    Since Microsoft has changed settings, PS1 script cannot be started from command line.