/build/static/layout/Breadcrumb_cap_w.png

How do you run an uninstall & install Powershell Script?

I have a silent uninstall & install script that I need to run. My question is how do I/can I run them both so it uninstalls the old version of the Software followed by installing the new version silently in the backgroup on the user machine? My eventual goal is to deploy the silent scripts via Group Policy in AD to about 80-100 users.  Script is below, thank you!

SILENT UNINSTALL: Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -eq "SOFTWARE NAME"} | foreach-object -process {$_.Uninstall()}

SILENT INSTALL:

$arguments="/quiet" 

Start-Process "\\SOMELOCATION\SOFTWARE.msi" $arguments

 


4 Comments   [ + ] Show comments
  • I would use another scriptlanguage for installing software cmd/vbs/AutoIT(or rather use commandline depending on application).
    Someone told me that powershell is better as a powerful console instead of using it as scripts for installing software. :)

    And powershell is restricted by default on win7 > so it needs to be launched from something else (like batch file with "Get-ExecutionPolicy unrestricted" and then the .ps1) - asman 11 years ago
  • >Someone told me that powershell is better as a powerful console instead of using it as scripts
    Well, that was useful for you because now you know for certain that you can henceforth ignore every word emanating from the lips of from whoever that was. Take a look at some of the sample scripts about: PS is more than just a console... - anonymous_9363 11 years ago
  • I'll look at some sample script and also I'm thinking running the 1st script then using a wait switch before the 2nd one is execute, I'll do a little digging and testing, but any additional input is appreciated. - sagunseanchetry 11 years ago
  • I'm all set I was able to call a batch uninstall file pause for about 30 seconds and then run the uninstall. This is thanks to some other forums and feedback from other folks. All this ran silently so I am set thank you for your feedback.

    Start-process "<path>"
    Start-Sleep -Seconds <#>
    $arguments="/quiet"
    Start-process "<path>"$arguments - sagunseanchetry 11 years ago

Answers (1)

Answer Summary:
Posted by: accesser 11 years ago
Yellow Belt
0

Not exactly what your after but I have a script that I use (via SCCM) to remove some software based on MSI GUID

 

 $PetrelHelp = get-WmiObject -Class Win32_Product -namespace "root\cimv2" | Where-object{$_.IdentifyingNumber -match "{A358CE96-C284-41EE-A2E6-1026CA546650}"}

$SDIDriver = get-WmiObject -Class Win32_Product -namespace "root\cimv2" | Where-object{$_.IdentifyingNumber -match "{0589B287-A7A8-465B-8370-548FC998F9A9}"}

$Petrel = get-WmiObject -Class Win32_Product -namespace "root\cimv2" | Where-object{$_.IdentifyingNumber -match "{108630B9-5EC1-4C90-BF0A-6587516C80A1}"}

if($PetrelHelp -ne $null)
{
(Start-Process -FilePath "msiexec.exe" -ArgumentList "/X {A358CE96-C284-41EE-A2E6-1026CA546650} /QN /L* C:\Windows\SOE\Logs\Petrel_Help_2012_Uninstall.log" -Wait -Passthru).ExitCode
}


if($SDIDriver -ne $null)
{

(Start-Process -FilePath "msiexec.exe" -ArgumentList "/X {0589B287-A7A8-465B-8370-548FC998F9A9} /QN /L* C:\Windows\SOE\Logs\SDI_APS_Driver_Installation_Uninstall.log" -Wait -Passthru).ExitCode

}

if($Petrel -ne $null)
{

(Start-Process -FilePath "msiexec.exe" -ArgumentList "/X {108630B9-5EC1-4C90-BF0A-6587516C80A1} /QN /L* C:\Windows\SOE\Logs\Schlumberger_Petrel2012x64_12.2.1.0_1.0_Uninstall.log" -Wait -Passthru).ExitCode
 
}

 

 

Comments:
  • Thanks for the both, but I was able to do a pause in between which worked out perfect, thanks.

    Start-Sleep -Seconds 25 - sagunseanchetry 11 years ago
    • I realize that this post is a couple years old, but...

      How would the start sleep be put into the script to get it to work properly? - Hairless Monkey 8 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ