Thursday, August 31, 2017

Oracle client installation - Windows - Powershell

 Write-Output "########################################################################"

# clear logfile content if it is exists

$ErrorActionPreference = 'SilentlyContinue'

Clear-Content G:\oracle_client_19c\logs\oracle_client_19c_win_Prereqs.log

Clear-Content G:\oracle_client_19c\oracle_client_19c_win_installation.log

Clear-Content G:\oracle_client_19c\logs\oracle_client_19c_win_post_check.log

#create client_home directory

mkdir G:\app\oracle\product\19.3.0\client_1

Write-Output "########################################################################"

#Extract software to client_home

Write-Output "Extract software start at $(Get-Date)"

expand-archive -path 'G:\oracle_client_19c\WINDOWS.X64_193000_client_home.zip' -destinationpath 'G:\app\oracle\product\19.3.0\client_1'

Write-Output "Extract software complete at $(Get-Date)"

Write-Output "########################################################################"

#client Prereqs

G:\app\oracle\product\19.3.0\client_1\setup.exe -executePrereqs -silent > G:\oracle_client_19c\logs\oracle_client_19c_win_Prereqs.log

#Oracle client installation

$Prereqs_status_output = cat G:\oracle_client_19c\logs\oracle_client_19c_win_Prereqs.log | Select-String -Pattern "Prerequisite checks executed successfully."

If ($Prereqs_status_output -eq $null) 

{

Write-Output "Prerequisite checks are not executed successfully"

} else {

Write-Output "Prerequisite checks executed successfully"

Write-Output "########################################################################"

Write-Output "Oracle client installation start at $(Get-Date)"

G:\app\oracle\product\19.3.0\client_1\setup.exe -responseFile "G:\oracle_client_19c\oracle_client_19c_win.rsp" -silent

Write-Output "Oracle client installation complete at $(Get-Date)"

}

Write-Output "########################################################################"