• Stars
    star
    249
  • Rank 157,694 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created over 1 year ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create MSIs using PowerShell.

Installers

PSMSI includes cmdlets for creating MSI packages that can contain any file and directory structure you wish. It also includes functionality to customize the installer interface by including custom EULAs and images.

Getting Started

To get started creating installers with PSMSI, you will need to download the latest version of the PSMSI module. This can be installed with Install-Module.

Install-Module PSMSI

WiX Toolset

This module is based on v3 of the Wix Toolset. There is so much more we could accomplish with this module. It mainly creates WiX XML and runs the WiX tools to generate MSIs. We're very open to PRs and issues. Feel free to check out the WiX documentation for features that could be added.

Creating your first installer

The New-Installer cmdlet is used to generate an installer. It can contain directories and files for installation. The first step is to define the basic parameters of your installer.

The Product and UpgradeCode parameters are required. The UpgradeCode is a GUID that needs to remain the same for each version of your product and should be unique from other products.

New-Installer -ProductName "My First Product" -UpgradeCode '1a73a1be-50e6-4e92-af03-586f4a9d9e82'

Within the Content parameter of the New-Installer cmdlet, you need to include a root directory for installation on the end user's machine. The root directory needs to be a predefined directory. One of the parameter sets on New-InstallerDirectory defines a PredefinedDirectory parameter that you can use to select the target root directory.

New-InstallerDirectory -PredefinedDirectory "LocalAppDataFolder"

You can now optionally specify a nested directory within your root directory. This will be created if it does not exist and removed on uninstall.

New-InstallerDirectory -DirectoryName "My First Product"

Finally, you can include files within your directory. The New-InstallerFile cmdlet accepts a Source parameter with the path to the file you would like to install.

New-InstallerFile -Source .\MyTextFile.txt

The full script for this installer looks like this.

New-Installer -ProductName "My First Product" -UpgradeCode '1a73a1be-50e6-4e92-af03-586f4a9d9e82' -Content {
    New-InstallerDirectory -PredefinedDirectory "LocalAppDataFolder"  -Content {
       New-InstallerDirectory -DirectoryName "My First Product" -Content {
          New-InstallerFile -Source .\license.txt
       }
    }
 } -OutputDirectory (Join-Path $PSScriptRoot "output")

Running the above script will produce a WXS, WXSOBJ and MSI file in the output directory. The MSI is the only file that you need to provide to your end users. The WXS and WXSOBJ files are artifacts of the Windows Installer XML Toolkit used to generate these installers.

Installers

All Users Installation

You can use the -RequriesElevation parameter of New-Installer to change from the default PerUser installation to a PerMachine installation.

The following creates an installer that will install to the program files folder.

New-Installer -ProductName "My First Product" -UpgradeCode '1a73a1be-50e6-4e92-af03-586f4a9d9e82' -Content {
    New-InstallerDirectory -PredefinedDirectory "ProgramFilesFolder"  -Content {
       New-InstallerDirectory -DirectoryName "My First Product" -Content {
          New-InstallerFile -Source .\license.txt
       }
    }
 } -OutputDirectory (Join-Path $PSScriptRoot "output") -RequiresElevation

Add\Remove Programs Icon

The Application Icon that will be displayed within Add\Remove Programs can be defined using the AddRemoveProgramsIcon of New-Installer.

New-Installer -Product "My First Product" -UpgradeCode '1a73a1be-50e6-4e92-af03-586f4a9d9e82' -Content {
    New-InstallerDirectory -PredefinedDirectory "ProgramFilesFolder"  -Content {
       New-InstallerDirectory -DirectoryName "My First Product" -Content {
          New-InstallerFile -Source .\license.txt
       }
    }
 } -OutputDirectory (Join-Path $PSScriptRoot "output") -AddRemoveProgramsIcon "icon.ico"

Upgrade Code

The UpgradeCode value should be static to ensure that upgrades work successfully. Define the upgrade code by on New-Installer.

New-Installer -ProductName "My First Product" -UpgradeCode '1a73a1be-50e6-4e92-af03-586f4a9d9e82' -Content {
    New-InstallerDirectory -PredefinedDirectory "ProgramFilesFolder"  -Content {
       New-InstallerDirectory -DirectoryName "My First Product" -Content {
          New-InstallerFile -Source .\license.txt
       }
    }
 } -OutputDirectory (Join-Path $PSScriptRoot "output") 

Version

The installer version is set using the Version parameter of New-Installer. You can provide upgrades by increasing the version and keeping the Upgrade Code the same.

The version defaults to 1.0.

New-Installer -ProductName "My First Product" -UpgradeCode '1a73a1be-50e6-4e92-af03-586f4a9d9e82' -Content {
    New-InstallerDirectory -PredefinedDirectory "ProgramFilesFolder"  -Content {
       New-InstallerDirectory -DirectoryName "My First Product" -Content {
          New-InstallerFile -Source .\license.txt
       }
    }
 } -OutputDirectory (Join-Path $PSScriptRoot "output") -Version 2.0

Custom Actions

Custom actions allow you to run PowerShell scripts during install and uninstall. You will need to include the script as a file in your installer. Use the FileId parameter of New-InstallerCustomAction to reference the PS1 file you wish to execute.

For example, you may have a script named MyCustomAction.ps1 with an ID of CustomAction.

New-InstallerFile -Source .\myCustomAction.ps1 -Id 'CustomAction'

You can then use that script as a custom action during an installation.

New-InstallerCustomAction -FileId 'CustomAction' -RunOnInstall

Arguments

You can pass arguments to both PowerShell.exe and your script. The Arguments parameter passes custom arguments to PowerShell.exe (like -NoProfile). The ScriptArguments parameter defines arguments to pass to the script itself.

CheckReturnValue

This checks the exit code of PowerShell.exe. If the exit code is non-zero, then it will cause the install to fail.

RunOnInstall

Runs the custom action during install.

RunOnUninstall

Runs the custom action during uninstall.

Directories and Files

You can create directories and files using New-InstallerDirectory and New-InstallerFile. Directories should start with one of the pre-defined directories provided by MSI.

Pre-defined Directories

Use the PredefinedDirectory parameter of New-InstallerDirectory to define the root folder for the installation. You can use directories such as Program Files, AppData and CommonAppData.

Custom Folders

Custom folders appear within pre-defined directories. You can nest folders to create a folder tree. Folders can then contain files. Use the DirectoryName parameter of New-InstallerDirectory to create a directory. Use Content to specify either folders or files to include.

Including the Configurable property on New-InstallerDirectory will allow the end user to select a directory during installation.

New-InstallerDirectory -DirectoryName "My First Product" -Content {
    New-InstallerFile -Source .\license.txt
} -Configurable

Files

Files are defined by their current location and an ID. The Source parameter should identify the file you wish to include. It's location in the New-InstallerDirectory tree will define where it is installed on disk.

New-InstallerDirectory -DirectoryName "My First Product" -Content {
    New-InstallerFile -Source .\license.txt
}

Shortcuts

Shortcuts can be defined for installers using New-InstallerShortcut. You will define where the shortcut is located using New-InstallerDirectory and reference a file by Id.

For example, to define a file by ID, you would include the Id parameter of New-InstallerFile.

New-InstallerFile -Source .\MyTextFile.txt -Id "myTestFile"

Next, you would define the shortcut in a directory and reference the file by ID.

New-InstallerDirectory -PredefinedDirectory "DesktopFolder" -Content {
    New-InstallerShortcut -Name "My Test File" -FileId "myTestFile"
}

Working Directory

You can set the working directory of a shortcut by specifying the ID of the folder. The below example sets the working directory to the installation directory's ID.

New-Installer -ProductName "MyImage" -UpgradeCode (New-Guid) -Version 1.0.0 -Content {
    New-InstallerDirectory -PredefinedDirectoryName ProgramFilesFolder -Content {
        New-InstallerDirectory -DirectoryName 'MyDir' -Id 'MyDir' -Content {
            New-InstallerFile -Id 'Image' -Source 'services.png'
        }
    }
    New-InstallerDirectory -PredefinedDirectoryName DesktopFolder -Content {
        New-InstallerShortcut -Name 'Test' -FileId 'Image' -WorkingDirectoryId 'MyDir'
    }    
} -OutputDirectory .\installer -RequiresElevation

User Interfaces

You can customize the user interface of the installer by using the UserInterface parameter of New-Installer along with New-InstallerUserInterface.

User interfaces can include custom graphics and EULAs for your installer.

 $UserInterface = New-InstallerUserInterface -Eula (Join-Path $PSScriptRoot 'eula.rtf') -TopBanner (Join-Path $PSScriptRoot "banner.png") -Welcome (Join-Path $PSScriptRoot "welcome.png")

Ironman Software Free Tools

For more free tools, visit the Ironman Software free tools index.

More Repositories

1

universal-dashboard

Build beautiful websites with PowerShell.
JavaScript
443
star
2

psedit

A terminal-based editor for PowerShell
C#
242
star
3

terminal-gui-designer

A terminal GUI designer for PowerShell.
C#
132
star
4

powershell-universal

PowerShell Universal is the ultimate platform for building web-based IT tools.
PowerShell
127
star
5

code-conversion

Code conversion command line tool for PowerShell and C#
C#
111
star
6

findopenfiles

A PowerShell module for finding open files.
C#
72
star
7

pscommander

Automate your desktop with PowerShell.
C#
68
star
8

psavalonia

Avalonia bindings for PowerShell
PowerShell
56
star
9

universal-docs

Documentation for PowerShell Universal
47
star
10

ud-powershellexplorer

PowerShell Explorer shows information about the PowerShell environment on your machine.
PowerShell
41
star
11

poshud

Dashboard used for Poshud.com
PowerShell
38
star
12

issues

Public Issue tracker for Ironman Software products.
29
star
13

ud-forge

Desktops apps with Universal Dashboard
PowerShell
28
star
14

universal-dashboard-documentation

Documentation for PowerShell Universal Dashboard.
27
star
15

awesome-powershell-universal

A curated list of awesome PowerShell Universal resources.
26
star
16

poshprotools

Issue tracker and examples for PowerShell Pro Tools. Not maintained! Click here ->
25
star
17

universal-templates

Templates you can use to get started with Universal
PowerShell
24
star
18

plinqo

LINQ-Style PowerShell Methods
PowerShell
24
star
19

universal-automation

Universal Automation is the PowerShell-first automation platform.
24
star
20

universal-samples

Ironman Software PowerShell samples.
PowerShell
21
star
21

poshtools-docs

PowerShell Tools Documentation
20
star
22

ud-bginfo

Web-based BGInfo built on Universal Dashboard
PowerShell
19
star
23

powershell-protect

Audit and block PowerShell scripts.
C#
17
star
24

universal-active-directory

Active Directory dashboard for PowerShell Universal.
PowerShell
16
star
25

restore

Ctrl+Shift+T for PowerShell Terminals
PowerShell
12
star
26

universal-modules

PowerShell Universal modules that provide additional functionality to the platform.
PowerShell
12
star
27

ud-codeeditor

Code editor control for Universal Dashboard.
PowerShell
10
star
28

ud-custom-control-template

A custom control template for Universal Dashboard.
PowerShell
10
star
29

ud-outrest

Universal Dashboard REST API Generator for PowerShell
PowerShell
9
star
30

RuntimeDiagnostics

.NET Runtime diagnostic cmdlets.
C#
9
star
31

scripts

Public library of scripts maintained by Ironman Software.
PowerShell
9
star
32

windevtools

PowerShell
8
star
33

universal-automation-desktop

Universal Automation Desktop Edition
8
star
34

universal-code

Visual Studio Code extension for PowerShell Universal
TypeScript
8
star
35

pswindows

Manipulate Windows in Microsoft Windows with PowerShell.
C#
7
star
36

ud-chatroom

A chatroom example to demonstrate real-time elements.
PowerShell
7
star
37

ud-factory

Tools for creating custom components and frameworks for PowerShell Universal.
JavaScript
7
star
38

ud-sparklines

Sparklines controls for Universal Dashboard
PowerShell
6
star
39

universal-dashboard-component

Universal Dashboard v3 Component template repository.
PowerShell
5
star
40

ud-material-design

Material Design components for PowerShell Universal Dashboard.
PowerShell
4
star
41

dashboard-utils

Utilities for PowerShell Universal Dashboards.
PowerShell
4
star
42

ud-leaflet

A map component for Universal Dashboard
PowerShell
4
star
43

universal-automation-documentation

4
star
44

universal-azure-actions

GitHub actions for deploying PowerShell Universal to Azure.
PowerShell
3
star
45

ud-clock

A clock built with PowerShell Universal Dashboard
PowerShell
3
star
46

ud-diagrams

Diagrams for Universal Dashboard
PowerShell
3
star
47

ud-moment

Time and Date component for Universal Dashboard.
PowerShell
3
star
48

searchindex

Search Index cmdlet example.
C#
3
star
49

local-accounts

Local Accounts Dashboard
PowerShell
3
star
50

chuck-norris-jokes

Example Electron App and PowerShell Installer
HTML
3
star
51

ud-jea

Universal Dashboard for managing JEA endpoints and allowing access to JEA tools.
PowerShell
3
star
52

ud-calendar

Calendar for Universal Dashboard
PowerShell
3
star
53

ud-hyperv

Hyper-V Dashboard
PowerShell
2
star
54

ud-style

Emotion support for Universal Dashboard
PowerShell
2
star
55

ud-deployment

Example deployment script using Universal Dashboard
PowerShell
2
star
56

ud-weather

Weather dashboard for Universal Dashboard
PowerShell
2
star
57

universal-icons

Repository of Icon libraries for PowerShell Universal apps.
PowerShell
2
star
58

universal-dashboard-enterprise

This repository contains releases of Universal Dashboard Enterprise.
2
star
59

ud-syntaxhighlighter

Syntax Highlighter for Universal Dashboard
PowerShell
2
star
60

universal-landing-page

A dashboard landing page that generates based on your defined dashboards.
PowerShell
2
star
61

ud-pghero

A performance dashboard for Postgres
PowerShell
1
star
62

ud-helmet

React Helmet support for Universal Dashboard
PowerShell
1
star
63

ud-knob

Knob control for Universal Dashboard
JavaScript
1
star
64

poshud.com

Docker container for PoshUD.com
PowerShell
1
star
65

universal-dashboard-marketplace

Universal Dashboard Marketplace
C#
1
star
66

csharp-winform-designer

Documentation and Issues tracker for the C# WinForm Designer for VS Code
1
star
67

powershell-universal-template

A template repository for creating and publishing PowerShell Universal Templates
1
star
68

whats-next

CSS
1
star
69

universaldashboard.io

UniversalDashboard.io website.
HTML
1
star
70

ud-95

PowerShell
1
star
71

ud-gridlayout

UDGridLayout component for Universal Dashboard.
PowerShell
1
star
72

poshtools-issues

Issue tracker for PowerShell Pro Tools
1
star
73

ud-jspacker

Universal Dashboard JavaScript framework packager.
1
star
74

universal-docker

Docker images for PowerShell Universal.
PowerShell
1
star
75

universal-database-explorer

A MS SQL database explorer.
PowerShell
1
star