Skip to content

msi_install_from_url.ps1

Corey Watson edited this page Dec 24, 2025 · 2 revisions

msi_install_from_url.ps1

Downloads and silently installs an MSI package from a specified URL.

Overview

Downloads and silently installs an MSI package from the URL specified in $MsiScriptUrl. The file is saved to the temporary directory and cleaned up after installation completes.

Purpose

Downloads and silently installs an MSI package from the URL specified in $MsiScriptUrl. The file is saved to the temporary directory and cleaned up after installation completes.

Prerequisites

  • PowerShell 5.1+
  • Admin rights
  • Network connectivity

Configuration

Required Inputs

Edit $MsiScriptUrl with the full URL to the MSI file.

Settings

  • Uses curl for fastest, most reliable downloads with automatic redirect handling
  • Fallback filename logic for URLs without valid filenames or .msi extensions
  • Full decimal precision (no rounding)
  • Uses PowerShell defaults for timeouts

Behavior

  1. Validates URL and prepares temp directory path
  2. Downloads MSI file using curl with redirect following
  3. Verifies downloaded file exists and reports size
  4. Executes silent MSI installation via msiexec
  5. Cleans up temporary MSI file
  6. Reports installation success or failure
  7. Exits 0 on success (including code 3010 for reboot required), exits 1 on failure

Security Notes

  • No secrets logged
  • Downloads only from the specified URL
  • Temporary files cleaned up after installation

Exit Codes

  • 0 : Success (includes msiexec exit codes 0 and 3010)
  • 1 : Failure (download error or msiexec non-zero exit code)

Example Output

[ DOWNLOAD AND INSTALL ]
--------------------------------------------------------------
 MSI Source URL  : https://example.com/installer.msi
 Filename Used   : installer.msi
 Temporary Path  : C:\Users\admin\AppData\Local\Temp\installer.msi
 STARTING DOWNLOAD (CURL)...
 Download Status : SUCCESS
 File Size       : 45.8 MB

 Installation Status : STARTING SILENT INSTALL
 Command Executed    : msiexec /i "C:\Users\admin\AppData\Local\Temp\installer.msi" /qn /norestart
 Process Exit Code   : 0

[ FINAL STATUS ]
--------------------------------------------------------------
 Cleanup Result  : SUCCESSFUL
 INSTALLATION COMPLETED SUCCESSFULLY

[ SCRIPT COMPLETED ]

Version History

  • v1.5.0 (2025-10-30) - Switched to curl for fastest, most reliable downloads with automatic redirect handling and better error reporting.
  • v1.4.0 (2025-10-30) - Added fallback filename logic for URLs without valid filenames or .msi extensions.
  • v1.3.0 (2025-09-22) - Minimal version, removing all non-essential diagnostic placeholders and sections as requested.
  • v1.2.0 (2025-09-22) - Reduced placeholders; adopted $MsiScriptUrl variable.
  • v1.1.0 (2025-09-22) - Added $MsiUrl variable and logic for download/install.
  • v1.0.0 (2025-09-22) - Initial release: silent MSI install wrapper.

Links

Clone this wiki locally