PACE Suite - Application Packaging & Virtualization Software PACE Suite - Application Packaging & Virtualization Software

    Request a quote
    Please fill in this quick form and we will send you a free quote shortly.
    I have read and agree to the Privacy Policy
    [recaptcha]

      Request a quote
      Please fill in this quick form and we will send you a free quote shortly.
      I have read and agree to the Privacy Policy
      [recaptcha]

        Contact PACE Products Team
        Please fill in this quick form to contact our expert directly.
        I have read and agree to the Privacy Policy
        [recaptcha]

        Run PowerShell Script from MSI

        PowerShell is a tool and a framework created by Microsoft to take a load off IT pros’ feet by configuring and automating their tasks. This engine automates tasks with standard .NET classes, cmdlets, executables, and scripts. So, now let’s look closer at how you can run a PS script from MSI.

        What is a PowerShell script?

        A script is a set of instructions saved in a text file (with the extension “.ps1”) that PowerShell understands and executes in sequence to accomplish a task. PowerShell remains a favourite tool of system administrators because they can script alsmost any task with PowerShell (by the way, here is a handy guide on creating and editing scripts from Microsoft).

        How to run PowerShell script from MSI in PACE Suite?

        We use PACE Suite for application packaging to showcase how you can quickly run a PowerShell script from an MSI package during installation. You can download the trial version of the tool and use it for 21 days, with no credit card required.



        As PACE Suite helps with all the tasks associated with MSI packaging, we’ll show how to import PowerShell script to the MSI package in our software packaging tool in order to execute script in PowerShell during the installation process.



        Two ways to run PowerShell from MSI:

        Import PowerShell script to MSI

        Before executing a PowerShell script, import the PowerShell script that you need to run to MSI.

        1. Go to the Package Designer in the Files and folders tab.

        Package Designer tab

        2. Select Import files from the context menu where you want to import the PowerShell script.

        package designer import

        3. Click Add > Add files to choose the script.

        add files

        4.Choose the PowerShell script from your file system and click Open.

        powershell import

        5. Tick the Complete operation with default settings option and click Finish.

        file import powershell

        Run PowerShell script from MSI via Custom Action

        1. Go to the Package Designer > Custom actions tab.

        custom actions package designer

        2. Click Add -> Custom action. The Wizard that opens takes into account each option you pick and at further steps, it disables options, which are incompatible with your previous choices, so in the end you get a working Custom Action.

        add custom actions

        3. Select Launch an EXE and click Next.

        launch exe

        4. Tick the Located on the system at the path, which is specified in the Command line field, in the selected working folder and click Browse…

        resources browse

        5. Select a folder, to which you have imported the PowerShell script and click Select.

        folder selection

        6. Enter the powershell.exe -ExecutionPolicy Bypass -File “ to the Command line field, where is a name of your imported PowerShell script with the file extension (e.g. psscript.ps1). Then, click Next.

        powershellexe

        NOTE -ExecutionPolicy Bypass parameter was added to ensure the Custom Action will always execute regardless of the current execution policy on the system. Select Deferred execution mode, Run in system context and An asynchronous execution that waits for exit code at the end of the sequence options, and click Next.

        choose execution mode

        7. Select Run after InstallFiles (or any other position, located below this) from the Execution sequence (recommended) list, if needed, specify execution conditions either by entering them manually or choosing from the drop-down list. Click Finish to add your custom action.

        identification powershell

        8. From the Execution sequence (recommended) list, select Run after InstallFiles (or any other position located below). If needed, specify the execution conditions – enter them manually or choose from the dropped list. Then, click Finish.

        sequencing powershell



        That is how easy it is to import and run PowerShell scripts from MSI packages using PACE Suite. Try our MSI authoring tool today to see what else can you do with our smart Wizards and convenient interfaces.