Powershell script to Upgrade custom software MSI packaged (InstallShield) across multiple servers in the domain

Posted on 2011-10-10
Last Modified: 2012-05-12
Hi People,

Can anyone here please help me in upgrading a custom MSI software that is already installed in multiple Windows Server 2003 and 2008 in my domain using powershell script ?

The following is the script that I've used to restart the service if present but obviously I need to reinstall the application from shared folders named \\FileServer1\folder1\CustomApp1.msi

any kind of assistance and help in modifying this script would be greatly appreciated.

$path = "C:\path\"
$serverlist = get-content "$path\serverlist.txt"
$servicename = "CustomApp1"
foreach ($server in $serverlist) {
	 $result = Test-Connection $server -Count 1 -Quiet
	 if ($result -eq "True") {
		 $ServiceInstalled = Get-Service -name $servicename -ComputerName $server -ErrorAction SilentlyContinue
		 if ($ServiceInstalled.Name -ne $servicename) {
			Add-Content "$path\noservice.txt" -Value ("$server" + " " + "Service $servicename is not present")
		 else {
			 # Perform Install .MSI package
			 Start-Sleep -Seconds 60
			 sc.exe \\$server stop "$servicename"
			 Start-Sleep -Seconds 5
			 sc.exe \\$server start "$servicename"
			 Add-Content "$path\Installed.txt" -Value ("$server" + " " + "Service $servicename has been upgraded")
	 else {
		Add-Content "$path\noping.txt" -Value $server

Open in new window

    LVL 26

    Accepted Solution

    Is there a reason why you're not using the software installation capability within group policy for this? It would seem to me to be a much more dynamic and easier roll-out. You can use the WMI filter Win32_Service to determine if the service is installed as well.
    LVL 6

    Author Comment

    by:Senior IT System Engineer
    Yes that What I had in mind as well, but I need to know which servers failed to install ?

    Featured Post

    Do email signature updates give you a headache?

    Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

    Join & Write a Comment

    "Migrate" an SMTP relay receive connector to a new server using info from an old server.
    The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
    This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
    This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now