Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 590
  • Last Modified:

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

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

Senior IT System Engineer
Senior IT System Engineer
1 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.
Senior IT System EngineerIT ProfessionalAuthor Commented:
Yes that What I had in mind as well, but I need to know which servers failed to install ?

Featured Post

Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now