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
Answers (1)
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
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
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
Start-process "<path>"
Start-Sleep -Seconds <#>
$arguments="/quiet"
Start-process "<path>"$arguments - sagunseanchetry 11 years ago