cancel
Showing results for 
Search instead for 
Did you mean: 
jozsef_sarosi
GoTo Contributor

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.

4 REPLIES 4
jozsef_sarosi
GoTo Contributor

Re: How to execute PS1 files as Rescue Scripts (template)

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.

Rizwan324
New Member

Re: How to execute PS1 files as Rescue Scripts (template)

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.

 
 
 
 
 
 
johnabraham1122
New Member

Re: How to execute PS1 files as Rescue Scripts (template)

"To execute PS1 files as rescue scripts, ensure the PowerShell script is properly formatted, then use a task scheduler or automation tool to run it. You can also execute the script manually through PowerShell by typing .\scriptname.ps1. Make sure execution policies allow script running."
Rizwan86
New Member

Re: How to execute PS1 files as Rescue Scripts (template)

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.