Skip to content
Menu

Install an Application From a URL, Verified

Downloads an installer over HTTPS, verifies it by SHA-256 or a trusted publisher signature, installs it silently and checks the installed entry if DetectName is set.

Install an application from a URL, verified is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Install an application from a URL, verified. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1, administrator rights, internet access to the URL
Changes thingsChanges what it runs on

What It Does

The script downloads the installer at Url into a temporary folder under ProgramData in the MSPOutpost folder, with 3 tries, checks it, runs it silently, optionally checks that the application is now listed as installed, and normally deletes the download. If the installer times out, it keeps the download folder because the installer may still be using it.

The file is never run until it is verified. If Sha256 is set, the download must match it exactly. If Sha256 is empty, the file must carry a valid Authenticode signature whose publisher is one of TrustedPublishers. With neither, the script refuses before it downloads anything. Only https:// is accepted, and a redirect to a plain http:// address is refused. The file type is read from the downloaded bytes, not from the URL.

An .msi is run with msiexec /i and, unless Arguments already holds a /q switch, /qn /norestart. An .exe needs Arguments with its silent switches. Exit codes in SuccessCodes count as success, and 3010 is reported as a restart needed. If the installer returns 1641, the script reports that the installer already started a restart.

When DetectName is set and a matching application is already installed, the script does nothing and says so, so the same job can run on a schedule. With DetectName set, after a real install it must find that application, or it ends in ERROR.

Before You Run It

  • Take the SHA-256 from the vendor's own site, and use the file you will actually download.
  • Find the silent switches for an .exe installer before you run it. An .exe with no Arguments is refused.
  • Set DetectName so a scheduled run does not reinstall, and so the install is verified.
  • Run it with DryRun=true first. It downloads nothing and says what it would do.

Type and Risk

  • Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
  • Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
  • What it changes: Downloads an installer to a temporary folder, runs it, then deletes it.
  • Restart: It never restarts the machine itself. When a restart is needed to finish, the answer says so.
  • Typical run: 1 to 10 minutes.
  • Example answer: "Installed 7-Zip 26.00 (x64 edition) from www.7-zip.org; reboot needed"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • Url: The https:// address of the installer. Required.
  • Sha256: The expected SHA-256 of the file, 64 hex characters, from the vendor. Required unless TrustedPublishers is set. Default empty.
  • TrustedPublishers: Used only when Sha256 is empty: a list (comma or semicolon) of publisher names. The file must be validly signed and the signing certificate's name (CN) or organisation (O) must equal one of them, for example "Igor Pavlov". Default empty.
  • Arguments: Silent switches for the installer. For an .msi the default is /qn /norestart. Required for an .exe. Default empty.
  • SuccessCodes: Exit codes that mean success. Default 0,3010,1641.
  • DetectName: Name of the application as shown in Apps & features; * and ? work, and a name without a wildcard matches anywhere in the name. Skips the install when already present and verifies it afterwards. Default empty.
  • TimeoutMinutes: How long to wait for the installer. Whole number, 1 to 480. Default 30.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

install-application-from-url.ps1 · 1028 lines · 52.8 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.