Home Beginner's GuideHow to install Software Using PowerShell Script

How to install Software Using PowerShell Script

Automate Your Software Installation Process with PowerShell

by Divya Kiran Kumar
powershell

In this guide, I’ll walk you through how to install software using a PowerShell script. As someone who often manages multiple installations or needs to set up environments quickly, I’ve found PowerShell to be one of the most efficient tools available on Windows. Instead of manually running installers one by one, I can automate the entire process with just a few lines of code. In the sections ahead, I’ll explain how to write, customize, and execute PowerShell scripts to install software silently and reliably, saving both time and effort.

Although I mainly work on Linux systems, I sometimes need to install or manage software on Windows, such as VirtualBox, which I use to run Linux environments. That’s why I wrote this article: to show how PowerShell can make software installation on Windows simple and efficient, even for those more comfortable with Linux.

What is PowerShell?

For those who are not familiar, PowerShell is a task automation and configuration management framework from Microsoft. It consists of a command-line shell and associated scripting language built on the .NET Framework. In simpler terms, it’s like the Command Prompt but much more powerful.

Why use PowerShell for software installation?

  1. Efficiency: Automating software installations saves time, especially if you’re setting up multiple machines.
  2. Consistency: You can ensure that every machine has the same software installed in the same manner.
  3. Customization: PowerShell scripts can be customized to suit your specific needs, giving you greater control over the installation process.

Getting started with PowerShell

Before we dive into software installation, ensure that PowerShell is installed and set up on your machine. Most modern Windows systems come with it pre-installed. To check:

  1. Press Windows + X and choose “Windows PowerShell”.
  2. A blue window should appear. If it does, you’re good to go! If not, you might need to install or update PowerShell. Head over to the official Microsoft site for guidance.

Steps to install VirtualBox using PowerShell

Download the VirtualBox Installer

$url = "https://download.virtualbox.org/virtualbox/7.2.2/VirtualBox-7.2.2-170484-Win.exe"
$output = "$env:TEMP\VirtualBox-Installer.exe"
Invoke-WebRequest -Uri $url -OutFile $output

Tip: You can replace the URL above with the latest version from VirtualBox’s official downloads page: https://www.virtualbox.org/wiki/Downloads

Run the Installer Silently

Start-Process -FilePath $output -ArgumentList "--silent" -Wait -Verb RunAs
  • –silent installs VirtualBox without showing the setup wizard.
  • -Wait ensures PowerShell pauses until the installation completes.
  • -Verb RunAs runs it as Administrator (required for installation).

Verify the Installation

& "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" --version

If VirtualBox is installed correctly, this command will display the installed version number.

(Optional) Remove the Installer File

Remove-Item $output -Force

Troubleshooting common issues

Let’s face it, technology doesn’t always work as intended. So, if you face issues:

  1. Always double-check file paths: Ensure that the software installer is in the specified location.
  2. Run with proper permissions: Some software requires admin privileges. Right-click PowerShell and select “Run as administrator.”
  3. Check the installer’s silent installation options: Not all software uses /silent /install. You might need to visit the software’s official documentation or support forum for the correct parameters.

Conclusion

Installing software on Windows doesn’t have to be a repetitive task. With PowerShell, I can easily automate the entire process, from downloading to installing and verifying applications like VirtualBox. This method saves me time and keeps my setups consistent across different systems. Even though I usually work with Linux, I find PowerShell a reliable and efficient way to manage software on Windows.

You may also like

Leave a Comment