What is PowerShell and how to use it to customize your MSI

Written by Alex Marin · July 28th, 2023

In today’s software development industry, the partnership between PowerShell and MSI packaging continues to grow stronger.

In this article, we’ll explore the functionalities of PowerShell, its interaction with MSI, and how you can use PowerShell to customize your MSI.

NoteTo fully understand how MSI packaging has evolved over the years, don't miss our detailed article on the What are the Pros and Cons of using VBScript in MSI packaging, and see how PowerShell has become an influential player in today's software development landscape

Let's begin with a brief overview of PowerShell.

What is Microsoft PowerShell and what is it used for?

Microsoft PowerShell is the first cross-platform task automation solution, designed as a scripting language, out of a command-line shell, and a configuration management framework.

Before PowerShell, we didn’t have any cross-OS scripting languages that could bring together Windows, Linux and macOS.

PowerShell stands as a crucial tool for a variety of tasks in the digital space:

  • Automates system management, streamlining complex processes.
  • Provides building, testing, and deploying solutions in CI/CD environments.
  • Built on .NET Common Language Runtime (CLR), ensuring compatibility and ease of use.
  • Generates .NET objects as inputs and outputs, removing the need for parsing text output to gather necessary data.

However, we need to understand that during the development of the Windows Installer technology, PowerShell was still too new and way under development.

Microsoft decided to implement VBScript and JScript as the native recognized languages for MSIs. These allow you to add Custom Actions that extend the functionality of your installer, making MSI aware of how to connect to the Windows Script Host (WScript) service to run the custom actions at a specific stage.

While VBScript also allows the invocation of other system utilities, like the command prompt, there are fundamental differences between PowerShell and the command prompt:

  • PowerShell is an object-oriented task automation tool and scripting language.
  • Command prompt is a native Windows OS app, permitting users to perform tasks using commands.
  • Command prompt does not offer extensibility for functions, classes, or modules, unlike PowerShell.

How Were PowerShell Custom Actions Introduced?

Windows Installer technology hasn’t received an update for a while and it still doesn’t natively recognize PowerShell if you want to implement a Custom Action.

But, MSI does recognize the execution of a DLL as a custom action. This feature gave developers the idea to use this native functionality and modify it so you can create Custom Actions using PowerShell.

NoteCheck out this article for a more in-depth view on How To Execute Powershell Custom Actions in MSI.

With Advanced Installer you can use PowerShell in Custom Actions by embedding the code in the DLL during the build process.

Depending to the settings you perform, you can run the code during the:

  • installation;
  • modification;
  • or uninstallation phase.

Want to experience the seamless integration of PowerShell with Advanced Installer? Start a 30-day free trial today.

How are PowerShell Wrappers Helpful?

In earlier times, as an IT professional, you had limited options when it came to additional system checks or changes before or after an MSI installation. Your two main choices were:

  1. Batch files: These are script files containing a series of commands, similar to using the command prompt. They don't offer much versatility in scripting and often struggle with simple tasks like IF statements. Issues can also arise with null values in variables and escaped characters in strings.
  2. VBScript: This is a capable scripting language, still in use today. Its downside? No recent updates. This lack of development means tasks that now PowerShell cmdlets can easily handle used to be complex in VBScript, requiring lots of lines of code.

But then, PowerShell started to gain traction. Enterprises began to use their own script “templates” used by IT Pros for system alterations and MSI installations. Eventually, PowerShell App Deployment Toolkit (PSADT) was released as an open source alternative for the IT Professionals community.

PSADT has to main benefits:

  • It brings industry standardization.
  • It offers lots of extended functions, addressing common issues faced by IT professionals.

Today, PSADT is widely recognized as a prominent PowerShell wrapper.

How to Manipulate MSI Properties With PowerShell

Windows Installer technology offered the possibility to manipulate properties inside the MSI in multiple ways, including running Custom Actions.

This was a simple task with VBScript because all you were required to do was use the following codes:

- To retrieve MSI Properties inside the Custom Action:

strArgs = Session.Property("CustomActionData")
arrArgs = Split(strArgs, ";", -1, 1)
path1 = arrArgs(0)
path2 = arrArgs(1)

- To set MSI Properties inside the Custom Action:

Set WShell = CreateObject("WScript.Shell")
DISKID = WShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum\0")
Session.Property("DISKID") = DISKID

With PowerShell, the task of manipulating MSI properties was not so easy, since MSI technology does not natively recognize this language.

However, Advanced Installer noticed this gap and added the possibility to manipulate MSI Properties using PowerShell.

- To retrieve MSI Properties inside a PowerShell Custom Action:

$propValue = AI_GetMsiProperty YOUR_PROP

- To set MSI Properties inside a PowerShell Custom Action:


MSI Build Automation using PowerShell

With Advanced Installer, you get a command line interface designed to facilitate the need for automation. This means you can create, build, or edit your projects with ease.

Advanced Installer comes with custom PowerShell commands. These allow you to:

  • Create and configure Advanced Installer projects;
  • Completely automate your project updates and CI/CD build pipelines.

And there's more - PowerShell makes it possible to manage various aspects of your project, including:

  • Managing files and folders,
  • Getting license information,
  • Accessing components, and more.

So, if you're looking for a tool to streamline your application packaging tasks, Advanced Installer is worth considering.


Although PowerShell was not as widely used as now when the Windows Installer technology was developed, and it was not adopted natively into the MSI, many years after its release there are still improvements being made.

Nowadays, IT Pros can rely on most used technologies to help them achieve the best installers with minimal effort.

For any questions on MSI technology or PowerShell, leave your comments below.

Written by
See author's page
Alex Marin

Application Packaging and SCCM Deployments specialist, solutions finder, Technical Writer at Advanced Installer.