Blog

Software Installation Made Easy with PowerShell

10/22/2024 2 min read

Today I want to show a clever method to significantly simplify software installations. Imagine having a script that automatically installs required software on a machine. That's handy—but it gets even easier.

Software Installation Made Easy with PowerShell

The idea:
All installation files are stored together in one folder, and the script accesses them simply by filename.


Why This Is a Gamechanger

This sounds trivial at first but has huge advantages:

  • No more changing paths
  • No need to adjust the script for new versions
  • Clear, reproducible installations

The script runs and immediately finds the matching file. This saves time and reduces errors.


Practical Example

Suppose you use a PowerShell script that searches for MSI files on a server or network share:

  • Check if the file exists
  • Copy it to the local machine
  • Execute the installation

Simple, reliable, automatable.


The Decisive Advantage During Updates

When an update comes, you only replace the file in the folder.
The filename stays the same—the script remains unchanged.

Result:

  • No script modifications
  • No distributing new versions
  • A central location for all updates

This is especially valuable when managing multiple computers or entire networks.


Consistency and Error Reduction

Since every installation runs exactly the same way:

  • Fewer manual errors
  • Easier troubleshooting
  • Clean, traceable process

Fixing a script is much easier than searching for installation errors on individual machines.


Conclusion

Collect all software in one folder and install via script:

  • Saves time
  • Reduces errors
  • Makes updates trivial

Once set up, you won't want to manage it any other way.


Example Script (PowerShell)

$UNCPath = "\\Server\Share\Software\"
$FilePrefix = "Dateiname" # adjust desired filename
$MSIParams = "/qn"        # additional MSI parameters optional
$TargetPath = "C:\temp"  # local destination folder

# Search for MSI files with the defined prefix
$MSIFiles = Get-ChildItem -Path $UNCPath -Filter "$FilePrefix*.msi"

# Check if matching files were found
if ($MSIFiles.Count -eq 0) {
    Write-Host "No matching MSI file found. Script will exit."
    exit
} elseif ($MSIFiles.Count -gt 1) {
    Write-Host "Multiple matching MSI files found. Using the first file."
}

$MSIFileName = $MSIFiles[0].Name
$FullUNCPath = Join-Path $UNCPath $MSIFileName
$LocalFile   = Join-Path $TargetPath $MSIFileName

# Create target folder if it does not exist
if (-not (Test-Path $TargetPath)) {
    New-Item -Path $TargetPath -ItemType Directory -Force | Out-Null
}

# Copy MSI file locally
Copy-Item -Path $FullUNCPath -Destination $LocalFile -Force

# Start installation
Start-Process -FilePath "msiexec.exe" `
    -ArgumentList "/i `"$LocalFile`" $MSIParams" `
    -Wait -NoNewWindow

# Optional: delete MSI after installation
# Remove-Item -Path $LocalFile -Force