• Stars
    star
    254
  • Rank 160,264 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created about 2 years ago
  • Updated 4 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
446
star
2

psedit

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

terminal-gui-designer

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

powershell-universal-legacy

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

code-conversion

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

findopenfiles

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

pscommander

Automate your desktop with PowerShell.
C#
70
star
8

psavalonia

Avalonia bindings for PowerShell
PowerShell
59
star
9

universal-docs

Documentation for PowerShell Universal
50
star
10

gallery

Public gallery of modules for PowerShell Universal
PowerShell
49
star
11

powershell-pro-tools

Scripting, automation, and development tools for professionals working with PowerShell.
C#
46
star
12

ud-powershellexplorer

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

poshud

Dashboard used for Poshud.com
PowerShell
38
star
14

powershell-universal

Issue tracker for PowerShell Universal
35
star
15

awesome-powershell-universal

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

ud-forge

Desktops apps with Universal Dashboard
PowerShell
28
star
17

universal-dashboard-documentation

Documentation for PowerShell Universal Dashboard.
27
star
18

plinqo

LINQ-Style PowerShell Methods
PowerShell
25
star
19

poshprotools

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

universal-templates

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

universal-automation

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

universal-samples

Ironman Software PowerShell samples.
PowerShell
21
star
23

powershell-protect

Audit and block PowerShell scripts.
C#
20
star
24

ud-bginfo

Web-based BGInfo built on Universal Dashboard
PowerShell
20
star
25

poshtools-docs

PowerShell Tools Documentation
19
star
26

universal-active-directory

Active Directory dashboard for PowerShell Universal.
PowerShell
18
star
27

universal-modules

PowerShell Universal modules that provide additional functionality to the platform.
PowerShell
13
star
28

restore

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

ud-codeeditor

Code editor control for Universal Dashboard.
PowerShell
10
star
30

RuntimeDiagnostics

.NET Runtime diagnostic cmdlets.
C#
10
star
31

ud-custom-control-template

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

ud-outrest

Universal Dashboard REST API Generator for PowerShell
PowerShell
9
star
33

windevtools

PowerShell
8
star
34

pswindows

Manipulate Windows in Microsoft Windows with PowerShell.
C#
8
star
35

universal-automation-desktop

Universal Automation Desktop Edition
8
star
36

universal-code

Visual Studio Code extension for PowerShell Universal
TypeScript
8
star
37

ud-chatroom

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

ud-factory

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

ud-sparklines

Sparklines controls for Universal Dashboard
PowerShell
6
star
40

universal-dashboard-component

Universal Dashboard v3 Component template repository.
PowerShell
5
star
41

ud-material-design

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

searchindex

Search Index cmdlet example.
C#
4
star
43

dashboard-utils

Utilities for PowerShell Universal Dashboards.
PowerShell
4
star
44

ud-leaflet

A map component for Universal Dashboard
PowerShell
4
star
45

universal-automation-documentation

4
star
46

universal-azure-actions

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

ud-diagrams

Diagrams for Universal Dashboard
PowerShell
3
star
48

ud-moment

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

ud-clock

A clock built with PowerShell Universal Dashboard
PowerShell
3
star
50

local-accounts

Local Accounts Dashboard
PowerShell
3
star
51

chuck-norris-jokes

Example Electron App and PowerShell Installer
HTML
3
star
52

ud-jea

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

ud-calendar

Calendar for Universal Dashboard
PowerShell
3
star
54

ud-style

Emotion support for Universal Dashboard
PowerShell
2
star
55

ud-hyperv

Hyper-V Dashboard
PowerShell
2
star
56

ud-deployment

Example deployment script using Universal Dashboard
PowerShell
2
star
57

csharp-winform-designer

Documentation and Issues tracker for the C# WinForm Designer for VS Code
2
star
58

ud-weather

Weather dashboard for Universal Dashboard
PowerShell
2
star
59

universal-icons

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

universal-windows-performance

Windows Performance dashboard and scripts.
PowerShell
2
star
61

ud-syntaxhighlighter

Syntax Highlighter for Universal Dashboard
PowerShell
2
star
62

universal-powershell-explorer

A dashboard that provides information about the current PowerShell environment.
PowerShell
2
star
63

universal-landing-page

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

universal-dashboard-enterprise

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

ud-pghero

A performance dashboard for Postgres
PowerShell
1
star
66

ud-helmet

React Helmet support for Universal Dashboard
PowerShell
1
star
67

ud-knob

Knob control for Universal Dashboard
JavaScript
1
star
68

ud-95

PowerShell
1
star
69

poshud.com

Docker container for PoshUD.com
PowerShell
1
star
70

universal-dashboard-marketplace

Universal Dashboard Marketplace
C#
1
star
71

powershell-universal-template

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

whats-next

CSS
1
star
73

universaldashboard.io

UniversalDashboard.io website.
HTML
1
star
74

ud-gridlayout

UDGridLayout component for Universal Dashboard.
PowerShell
1
star
75

poshtools-issues

Issue tracker for PowerShell Pro Tools
1
star
76

universal-docker

Docker images for PowerShell Universal.
PowerShell
1
star
77

ud-jspacker

Universal Dashboard JavaScript framework packager.
1
star
78

universal-database-explorer

A MS SQL database explorer.
PowerShell
1
star