PowerShell install one-click deployment of Oracle_client21

Foreword to oracle

The relational database products developed by Oracle are famous for their excellent performance. Oracle database products are used by the top 1,000 companies on the fortune list, and many large websites also use the Oracle system, which is the best database product in the world. In addition, Oracle Corporation develops other applications and software. At the same time, Oracle also means “oracle” in English, which means “speaking for God”, implying the development goals and determination status of Oracle Corporation.

download Oracle

oracle 21c needs an oral account oracle more Baidu Cloud Document
download download Reference

Prerequisites

  • Open wmi, configure the network card, refer to

One-click deployment of Oracle_cliert21

  • , cannot be downloaded online, please download it offline or upload it to the internal http server of the host, and change the installation location and user
  • ORACLE_HOME=C:\app\client\Administrator\product\21.0.0\client_1
  • ORACLE_BASE=C:\app\client\Administrator
  • oracle.install.client.installType=Administrator
  • oracle.install.client.drdaas.portNumber=1446
powershell-install-oracle_client.ps1
<# Powershell Install oracle_client
 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 + _____ _____ _ _ _ +
 + | __ \ / ____| | | | | +
 + | |__) |____ _____ _ _| (___ | |__ ___| | | +
 + | ___/ _ \ \ /\ / / _ \ '__\___ \| '_ \ / _ \ | | +
 + | | | (_) \ V V / __/ | ____) | | | | __/ | | +
 + |_| \___/ \_/\_/ \___|_| |_____/|_| |_|\___|_|_| +
 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

#Obtain installation and configuration parameters
c:\client\setup.exe -help
-help - Displays the help.
-silent - Runs in no-prompt mode. The input can be a response file or a list of command line variable value pairs.
[-ignoreprereqFailure - Ignore all prerequisite check failures.]
[-LenientInstallMode - Performs "best effect" installation by automatically ignoring invalid data in input parameters.]
[-showprogress - Displays the installation progress on the console. This option is supported only in silent mode.]
-responseFile - Specifies the full path of the response file to use.
-jreLoc - Specifies the location of the jre to be used in the installation.
-logLevel - Enables message logging according to the priority provided by this parameter. Valid options include: Serious, Warning, Message, Configuration, Detailed, More Detailed, Very Detailed.
-paramFile - Specifies the location of the oraparam.ini file to be used in the installation.
-executePrereqs | -executeConfigTools | -deinstall
-executePrereqs - Performs prereQs only.
-executeConfigTools - Executes the configuration tool on the installed home directory.
-deinstall - Uninstalls the specified home directory.
-debug - Runs in debug mode.
-executeSysPrereqs - Performs a system prerequisite check and exit.
-ignoreSysPrereqs - ignores the result of the system prerequisite check.
-printdiskusage - Records the debugging information about diskusage.
-printmemory - Records debugging information about memory usage.
-waitForCompletion - Waits for the installation to complete rather than spawn-off the installer and returning the console prompt.
-suppressPreCopyScript - SuppressprecopyScript - Disables pre-replication script execution.
- acceptUntrustedCertificates - accept not trusted certificate from secure sites.
-suppressPostCopyScript - SuppresspostCopyScript - Disables post-copy script execution.
-noconfig - Do not run the configuration tool.
-noconsole - Disables the display of messages in the console. The console is not assigned.
- ignoreInternalDriverError - ignore any internal driver error.
-promptForPassword - Specifies the password provided on the console during the Oracle database installation.

# Powershell Install oracle_client
# .\powershell-install-oracle_client.ps1
#>


function Install-oracle_client {
   if (-not ( Get-ItemProperty HKLM:\SOFTWARE\Oracle\KEY_OraClient21Home1 -ErrorAction SilentlyContinue)) {
      if ($?) {
\t\t  
$drive="c:"
$oracle_clent_install="setup.exe"
$oracle_clent="client"
$oracle_client_url="https://download.oracle.com/otn/nt/oracle21c/213000/WINDOWS.X64_213000_client.zip?AuthParam=1684725971_bb2c045515abc8a335780b5bd37f7a98"
$oracle_client_zip="WINDOWS.X64_213000_client.zip"
$oracle_client_environmen="C:\app\client\Administrator\product\21.0.0\client_1\bin"

$vc_redist_64 = "vc_redist.x64.exe"
$vc_redist_86 = "vc_redist.x86.exe"

Write-Host "download Oracle_client 21c" -ForegroundColor Green
Invoke-WebRequest -Uri $oracle_client_url -OutFile $drive\$oracle_client_zip

$vc_related_download = @(
           #"$oracle_client_url",
           "https://aka.ms/vs/17/release/$vc_redist_64",
           "https://aka.ms/vs/17/release/$vc_redist_86"
)

foreach ($url in $vc_related_download) {
           $fileName = Split-Path $url-Leaf
           $filePath = Join-Path $drive\ $fileName
         Invoke-WebRequest -Uri $url -OutFile $filePath
}

Write-Host "install vc_redist x86 x64" -ForegroundColor Green
Start-Process -FilePath "$drive\$vc_redist_64" -ArgumentList {/q /install} -Wait
Start-Process -FilePath "$drive\$vc_redist_86" -ArgumentList {/q /install} -Wait

Write-Host "Unzip the oralce_client installation file" -ForegroundColor Green
Expand-Archive -Path $drive\$oracle_client_zip -DestinationPath $drive

$oracle_client_rsp="client.rsp"
$responseFileclient = @"
#################################################### ###############################
## Copyright(c) Oracle Corporation 1998,2021. All rights reserved. ##
## ##
## Specify values for the variables listed below to customize ##
## your installation. ##
## ##
## Each variable is associated with a comment. The comment ##
## can help to populate the variables with the appropriate ##
## values. ##
## ##
#################################################### ###############################


#------------------------------------------------- ------------------------------
# Do not change the following system generated value.
#------------------------------------------------- ------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_clientinstall_response_schema_v21.0.0

#------------------------------------------------- ------------------------------
# Unix group to be set for the inventory directory.
#------------------------------------------------- ------------------------------
UNIX_GROUP_NAME=
#------------------------------------------------- ------------------------------
# Complete path of the Oracle Home
#------------------------------------------------- ------------------------------
ORACLE_HOME=C:\app\client\Administrator\product\21.0.0\client_1
#------------------------------------------------- ------------------------------
# Complete path of the Oracle Base.
#------------------------------------------------- ------------------------------
ORACLE_BASE=C:\app\client\Administrator
#------------------------------------------------- -----------------------------------------------
# Specify the Oracle Home user.
#
# Use Built-in Account or specify a Windows User Account with limited privilege to
# install and configure the Oracle Home.
#
# Set oracle.install.IsBuiltInAccount to true if you want to use BuiltIn Account.
#
# Set oracle.install.IsBuiltInAccount to false if you want to use Windows Account
# user as Oracle Home user.
#------------------------------------------------- -----------------------------------------------
oracle.install.IsBuiltInAccount=true
oracle.install.OracleHomeUserName=
oracle.install.OracleHomeUserPassword=
#------------------------------------------------- -----------------------------
#Name : INSTALL_TYPE
#Datatype : String
#Description: Installation type of the component.
#
# The following choices are available. The value should contain
# only one of these choices.
# - Administrator
# - Runtime
# - InstantClient
# - Custom
#
#Example : INSTALL_TYPE = Administrator
#------------------------------------------------- -----------------------------
oracle.install.client.installType=Administrator

#------------------------------------------------- ------------------------------
# Name: oracle.install.client.customComponents
# Datatype : StringList
#
# This property is considered only if INSTALL_TYPE is set to "Custom"
#
# Description: List of Client Components you would like to install
#
# The following choices are available. You may specify any
# combination of these choices. The components you choose should
# be specified in the form "internal-component-name:version"
# Below is a list of components you may specify to install.
#
# oracle.sqlj:21.0.0.0.0 -- "Oracle SQLJ"
# oracle.rdbms.util:21.0.0.0.0 -- "Oracle Database Utilities"
# oracle.javavm.client:21.0.0.0.0 -- "Oracle Java Client"
# oracle.sqlplus:21.0.0.0.0 -- "SQL*Plus"
# oracle.dbjava.jdbc:21.0.0.0.0 -- "Oracle JDBC/THIN Interfaces"
# oracle.ldap.client:21.0.0.0.0 -- "Oracle Internet Directory Client"
# oracle.rdbms.oci:21.0.0.0.0 -- "Oracle Call Interface (OCI)"
# oracle.precomp:21.0.0.0.0 -- "Oracle Programmer"
# oracle.xdk:21.0.0.0.0 -- "Oracle XML Development Kit"
# oracle.network.aso:21.0.0.0.0 -- "Oracle Advanced Security"
# oracle.oraolap.mgmt:21.0.0.0.0 -- "OLAP Analytic Workspace Manager and Worksheet"
# oracle.network.client:21.0.0.0.0 -- "Oracle Net"
# oracle.network.cman:21.0.0.0.0 -- "Oracle Connection Manager"
# oracle.network.listener:21.0.0.0.0 -- "Oracle Net Listener"
# oracle.ordim.client:21.0.0.0.0 -- "Oracle Multimedia Client Option"
# oracle.odbc:21.0.0.0.0 -- "Oracle ODBC Driver"
# oracle.dbdev:21.0.0.0.0 -- "Oracle SQL Developer"
# oracle.rdbms.scheduler:21.0.0.0.0 -- "Oracle Scheduler Agent"
# oracle.rdbms.drdaas:21.0.0.0.0 -- "Oracle Database Provider for DRDA"
# oracle.ntoramts:21.0.0.0.0 -- "Oracle Services For Microsoft Transaction Server"
# oracle.ntoledb:21.0.0.0.0 -- "Oracle Provider for OLE DB"
# oracle.ntoledb.odp_net_2:21.0.0.0.0 -- "Oracle Data Provider for .NET"
# oracle.aspnet_2:21.0.0.0.0 -- "Oracle Providers for ASP.NET"
#
#
# Example : oracle.install.client.customComponents="oracle.precomp:21.0.0.0.0","oracle.oraolap.mgmt:21.0.0.0.0","oracle.rdbms.scheduler:21.0 .0.0.0","oracle.rdbms.drdaas:21.0.0.0.0"
#------------------------------------------------- ------------------------------
oracle.install.client.customComponents=

#------------------------------------------------- ------------------------------
# Host name to be used for by the Oracle Scheduler Agent.
# This needs to be entered in case oracle.rdbms.scheduler is selected in the
# list of custom components during custom install
#
# Example : oracle.install.client.schedulerAgentHostName = acme.domain.com
#------------------------------------------------- -----------------------------
oracle.install.client.schedulerAgentHostName=

#------------------------------------------------- -----------------------------
# Port number to be used for by the Oracle Scheduler Agent.
# This needs to be entered in case oracle.rdbms.scheduler is selected in the
# list of custom components during custom install
#
# Example: oracle.install.client.schedulerAgentPortNumber = 1500
#------------------------------------------------- -----------------------------
oracle.install.client.schedulerAgentPortNumber=

#------------------------------------------------- -----------------------------
# Name: oracle.install.client.drdaas.hostName
# Datatype : String
# Description: Specify the host name or IP address of the DRDA AS Listener.
# Component : oracle.rdbms.drdaas
# This needs to be entered in case oracle.rdbms.drdaas is selected in the
# list of custom components during custom install
#------------------------------------------------- -----------------------------
 oracle.install.client.drdaas.hostName=
 
#------------------------------------------------- -----------------------------
# Name : oracle.install.client.drdaas.mapName
# Datatype : String
# Description: Specify the Relational Database Map Name for the DRDA AS Listener.
# Component : oracle.rdbms.drdaas
# This needs to be entered in case oracle.rdbms.drdaas is selected in the
# list of custom components during custom install
#------------------------------------------------- -----------------------------
 oracle.install.client.drdaas.mapName=
 
#------------------------------------------------- -----------------------------
# Name: oracle.install.client.drdaas.portNumber
# Datatype: int
# Description: Specify the port number of the DRDA AS Listener.
# Component : oracle.rdbms.drdaas
# This needs to be entered in case oracle.rdbms.drdaas is selected in the
# list of custom components during custom install
#------------------------------------------------- -----------------------------
 oracle.install.client.drdaas.portNumber=1446
 \t
#------------------------------------------------- -----------------------------
# Name : oracle.install.client.drdaas.connectionDescriptor
# Datatype : String
# Description: Specify the connection descriptor to use to connect to the Oracle Database. Acceptable values are:
#oracle_sid
# TNS(tnsnamesentry) (eg: TNS(orcl) )
# "TNS-Descriptor" (eg:"(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=drdaas))(CONNECT_DATA=(SERVICE_NAME=drdaas.us.oracle.com)))")
# Default: 'oracle_sid'
# Component : oracle.rdbms.drdaas
# This needs to be entered in case oracle.rdbms.drdaas is selected in the
# list of custom components during custom install
#------------------------------------------------- -----------------------------
oracle.install.client.drdaas.connectionDescriptor=
"@

Write-Host "oracle_client rsp" -ForegroundColor Green
$responseFileclient | Out-File $drive\$oracle_client_rsp -Encoding ASCII

Write-Host "install oracle_client" -ForegroundColor Green
Start-Process -FilePath $drive\$oracle_clent\$oracle_clent_install -ArgumentList "-silent -responseFile $drive\$oracle_client_rsp -lenientInstallMode -ignoreSysPrereqs -noconsole" -Wait

Write-Host "Create oracle_client environment variables" -ForegroundColor Green
$env:path += ";$oracle_client_environmen"
setx PATH $env:path /M

Write-Host "Delete oracle_client zip" -ForegroundColor Green
Remove-Item -Path "$drive\$oracle_client_zip", "$drive\$oracle_client_rsp", "$drive\*.exe" -Recurse -Force

        Write-Host "The oracale_client Install Success..." -ForegroundColor Green
        } else {
            Write-Host "The oracale_client Install Failed..." -ForegroundColor Red
            exit 1
        }
   
    } else {
        Write-Host "The oracale_client Install already..." -ForegroundColor Yellow
    }
 }
 
function Main {
    Install-oracle_client
}

Main

Perform installation

.\powershell-install-oracle_client.ps1

Installation output