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.
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'
}