Description

Install Java if previous or no version was detected and uninstall previous versions for security reasons.
This script install Java only if a previous version or no version was detected.
You can skip uninstallation of old versions with -NoUninstall switch.

Attached zip file contains two PowerShell scripts:

Requirements

Tested with latest version or PowerShell on Windows clients. Running latest Windows PowerShell Version is recomended.

Instructions for 64 bit installation

  1. Create shared folder to deploy Java Runtime Environment: \\FILESERVER-01\JRE
  2. Grant 'Authenticated users' read access to \\FILESERVER-01\JRE
  3. Download lastest version of 64 bit JRE from https://www.java.com/en/download/manual.jsp to: \\FILESERVER-01\JRE\jrex64.exe
  4. Copy 'InstallJava.ps1' to \\FILESERVER-01\JRE\InstallJava.ps1
  5. Create shared folder for logs: \\FILESERVER-01\JRE\logs
  6. Grant 'Authenticated users' write access to \\FILESERVER-01\JRE\logs
  7. Create a computer GPO that runs PowerShell Script:

Instructions for 32 bit installation

  1. Create shared folder to deploy Java Runtime Environment: \\FILESERVER-01\JRE
  2. Grant 'Authenticated users' read access to \\FILESERVER-01\JRE
  3. Download lastest version of 32 bits JRE from https://www.java.com/en/download/manual.jsp to: \\FILESERVER-01\JRE\jrex32.exe
  4. Copy 'InstallJava.ps1' to \\FILESERVER-01\JRE\InstallJava.ps1
  5. Create shared folder for logs: \\FILESERVER-01\JRE\logs
  6. Grant 'Authenticated users' write access to \\FILESERVER-01\JRE\logs
  7. Create a computer GPO that runs PowerShell Script:

Keep Java Runtime Environment Updated

Create a scheduled task on server that nightly executes 'DownloadJava.ps1' changing OutFile parameter to your server path.

 

 

PowerShell
Edit|Remove
<# 
.SYNOPSIS 
    Install Java Runtime Environment (jre) for Windows if previous or no version detected and uninstall previous versions. 
.DESCRIPTION 
    This script install Java Runtime Environment only if a previous version or no version was detected. 
    You can avoid uninstall old versions with -NoUninstall switch. 
.PARAMETER InstallPath 
    Java Runtime Environment full installer path. It could be download from https://www.java.com/en/download/manual.jsp. 
    Authenticated users must have read permissions over shared folder. 
    Example: \\FILESERVER-01\Skype\jre-10.0.2_windows-x64_bin.exe 
.PARAMETER LogPath 
    Log path (optional). ComputerName.log file will be created. 
    Authenticated users must have write permissions over log shared folder. 
    Example: \\FILESERVER-01\JRE\Logs (Log will be saved to \\FILESERVER-01\JRE\computername.log) 
.PARAMETER NoUninstall 
    Default: false. 
    Avoid uninstall previous versions before install Java Runtime Environment. 
.PARAMETER x64 
    Default: false. 
    64 bit version is selected for installing: InstallPath contains a 64 Bit JRE Installer. 
.EXAMPLE 
    Install 64 bit Java Runtime Environment from network share, saving log in Log folder of network share and uninstall previous versions. 
    Note: network share must have read permissions on "\\FILESERVER-01\JRE\" and write on "\\FILESERVER-01\JRE\Logs" for "Authenticated Users" group. 
    InstallJRE.ps1 "\\FILESERVER-01\JRE\jre-10.0.2_windows-x64_bin.exe" "\\FILESERVER-01\JRE\Logs" -x64 
.EXAMPLE 
    Install 32 bit Java Runtime Environment from network share, saving log in Log folder of network share and uninstall previous versions. 
    Note: network share must have read permissions on "\\FILESERVER-01\JRE\" and write on "\\FILESERVER-01\JRE\Logs" for "Authenticated Users" group. 
    InstallJRE.ps1 "\\FILESERVER-01\JRE\jre-8u181-windows-i586.exe" "\\FILESERVER-01\JRE\Logs" 
.NOTES  
    Author: Juan Granados  
    Date:   October 2018 
#>