Need a challenge? 1 script to install 2 to 3 different OS scenarios

Topics: Archive - General
Dec 17, 2014 at 3:09 PM
HI, This has just been beating me up, can you please shed some light?

I need to have my script install either the new 32/64bit msi check to see if a current 32bit app is installed on the 32or64 bit OS then “replace” which ever bitness app is already installed.

So 32bit msi to 32bit OS
Or 32bit msi to 64bit OS
Or 64bit msi to 64bit OS.

thanks,
Nos
Dec 17, 2014 at 9:43 PM
Do you have 64-bit systems where it is not installed or where you do not wish for it to be installed?
Dec 18, 2014 at 1:43 AM
It really depends on the requirements for your deployment.

This code would reflect what was already installed but it only suits an upgrade scenario because it would do nothing if Java was not already present on a system.
$InstalledApps = Get-InstalledApplication -Name "Java 7 Update"
Remove-MSIApplications -Name "Java 7 Update"

If ($InstalledApps | % {If ($_.Is64BitApplication -eq $False) {$True}}) {
    Execute-MSI -Action Install -Path '"$dirFiles\x86\jre1.7.0_71.msi'
} 
If ($InstalledApps | % {If ($_.Is64BitApplication -eq $True) {$True}}) {
    Execute-MSI -Action Install -Path '"$dirFiles\x64\jre1.7.0_71.msi'
 }
In installation scenario this would be better as long as computer targeting is controlled.
Remove-MSIApplications -Name "Java 7 Update"

If ($envArchitecture -eq "AMD64") {
    Execute-MSI -Action Install -Path '"$dirFiles\x86\jre1.7.0_71.msi'
    Execute-MSI -Action Install -Path '"$dirFiles\x64\jre1.7.0_71.msi'
 }
If ($envArchitecture -eq "x86") {
    Execute-MSI -Action Install -Path '"$dirFiles\x86\jre1.7.0_71.msi'
 }
Dec 18, 2014 at 1:50 AM
I would like to add that the | % will only work on Powershell version 3 +
Regular For Each Loops would have to be used on systems below version 3.
Dec 18, 2014 at 2:33 PM
Hey g4m3c4ck, can't wait to test it! I'l get back to you!

thanks,
Nos