How I Installed Software on a Server using PowerShell

I was tasked with installing custom and generic software on a dozen new servers. As an SDET, I have never done this type of task before, so I googled some methods for automating this process since manually installing each server was time-consuming. PowerShell seemed to be the logical tool for running through my list of tasks. I was able to install all the necessary programs in under three hours per server. Before this process, it took almost a whole day per server. The only requirement for the code below is PowerShell version 3.0 or later.

Connecting to Server Remotely

I decided to run this script remotely. This would eliminate all manual steps on my part when the machine was required to restart. I would not have to log onto the server multiple times when a restart occurred.

Installing Windows Updates

I noticed the servers I was given were out of date. I found a function for downloading and installing all available Windows updates. The module I found was from Be sure to run “Import-Module PSWindowsUpdate” first.

Custom Oracle Client

The biggest hiccup I had was installing the custom Oracle client directly from the PowerShell script. The documentation I found on Oracle’s page was and still is, incorrect. It is possible to install Oracle from PowerShell and with an optional parameter to pass a .rsp file. This .rsp file contains the settings needed for your custom Oracle install. The section which tripped me up was the custom components. The example directly from Oracle shows double quotes around each option separated by commas. This was the incorrect format, double quotes will throw an error when the command is run. The correct format is each custom component separated only by a comma. I figured this out by blind luck, but now I know for the future. The Oracle documentation also gives the format on how to run the setup installer with your .rsp file in the command line. In PowerShell, the command line can be reached by typing in cmd.exe and to exit, simply type exit. The -silent parameter at the end means the Oracle installer window will not display and the installer will run with no other input needed.

Message Queuing

The servers required the Message Queuing feature, Powershell has a nice way of achieving this.

Custom .msi Installation

As part of this process, a custom installer was required for an internal program. We have a location storing old versions of this installer alongside the current version. The naming convention is not always consistent, so I couldn’t find the latest version by the name. Instead, I used the file with the date most recently modified. I was also worried other file types might contaminate the installers folder, so I added a filter on the file type.

Emailing Log Files

I want to verify the error logs to ensure none of the installers logged any issues. Instead of logging into the server myself and opening the log, I emailed the log I wanted to myself.

Restart Server

Once the email was sent, I restarted the machine and logged off. Job done!

Leave a Reply

Your email address will not be published. Required fields are marked *