Created
May 5, 2023 14:59
-
-
Save iversond/4394ca3a6b4abaa885aeb6a96768a437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-----------------------------------------------------------[Parameters]---------------------------------------------------------- | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$true)][String]$ACCESS_ID, | |
[Parameter(Mandatory=$true)][String]$ACCESS_PWD, | |
[Parameter(Mandatory=$true)][String]$CONNECT_ID, | |
[Parameter(Mandatory=$true)][String]$CONNECT_PWD, | |
[Parameter(Mandatory=$true)][String]$OPR_ID, | |
[Parameter(Mandatory=$true)][String]$OPR_PWD, | |
[Parameter(Mandatory=$true)][String]$DATABASE, | |
[Parameter(Mandatory=$true)][String]$PT_VERSION, | |
[Parameter(Mandatory=$true)][String]$PT_PATCH, | |
[Parameter()][String]$CA_PATH = "C:\Program Files\PeopleSoft\Change Assistant" | |
) | |
#------------------------------------------------------------[Variables]---------------------------------------------------------- | |
. .\common.ps1 | |
$env:PATH="${env:ORACLE_HOME}\bin;${env:PATH}" | |
$env:TNS_ADMIN="${env:ORACLE_HOME}\network\admin" | |
$CLIENT_LOCATION="C:\PT${PT_VERSION}.${PT_PATCH}_Client_ORA" | |
$SQLPLUS_LOCATION="${env:ORACLE_HOME}\BIN\sqlplus.exe" | |
$CA_PATH="C:\Program Files\PeopleSoft\Change Assistant" | |
$CA_BASE="c:\ca" | |
$DATABASE=$DATABASE.toUpper() | |
function set_ca_paths { | |
Write-Output "Create CA Paths" | |
if (!(Test-Path $CA_BASE\output)) { New-Item -Path $CA_BASE\output -ItemType Directory } | |
if (!(Test-Path $CA_BASE\staging)) { New-Item -Path $CA_BASE\staging -ItemType Directory } | |
if (!(Test-Path $CA_BASE\download)) { New-Item -Path $CA_BASE\download -ItemType Directory } | |
} | |
function configure_ca { | |
Write-Output "Configure CA General Options" | |
Set-Location $CA_PATH | |
$CA_VERSION = $(gc .\CAInstanceName.txt).split(' ')[3] | |
& "${CA_PATH}\changeassistant.bat" ` | |
-MODE UM -ACTION OPTIONS ` | |
-OUT "${CA_BASE}\output\ca.log" ` | |
-REPLACE Y ` | |
-EXONERR Y ` | |
-SWP False ` | |
-MCP 5 ` | |
-PSH "C:\PT${CA_VERSION}_Client_ORA" ` | |
-STG "${CA_BASE}\staging" ` | |
-OD "${CA_BASE}\output" ` | |
-DL "${CLIENT_LOCATION}\PTU" ` | |
-SQH "${SQLPLUS_LOCATION}" ` | |
-EMYN N ` | |
-SRCYN N | |
if (!($LASTEXITCODE -eq 0)) { | |
Write-Error "Error configuring Change Assistant. Check database name: [${DATABASE}] (did you use upper case?)" | |
Exit 1 | |
} | |
} | |
function create_environment { | |
Write-Output "Create CA Environment: ${DATABASE}" | |
Set-Location $CA_PATH | |
.\changeassistant.bat ` | |
-MODE UM -ACTION ENVCREATE ` | |
-TGTENV $DATABASE ` | |
-REPLACE Y ` | |
-CKYN Y ` | |
-CT 2 ` | |
-CA "${ACCESS_ID}" ` | |
-CAP "${ACCESS_PWD}" ` | |
-CO "${OPR_ID}" ` | |
-CP "${OPR_PWD}" ` | |
-CI "${CONNECT_ID}" ` | |
-CW "${CONNECT_PWD}" ` | |
-SQH "${SQLPLUS_LOCATION}" ` | |
-PSH "${CLIENT_LOCATION}" ` | |
-PAH "${CLIENT_LOCATION}" ` | |
-PCH "${CLIENT_LOCATION}" ` | |
-SQRF "'-ZIF${CLIENT_LOCATION}\sqr\pssqr.ini'" | |
if (!($LASTEXITCODE -eq 0)) { | |
Write-Error "Error configuring New PS_HOME for ${DATABASE}. Open Change Assistant to review the configuration." | |
Set-Location $START_LOCATION | |
Exit 1 | |
} | |
} | |
#------------------------------------------------------------[Main]---------------------------------------------------------- | |
$START_LOCATION = get-location | |
. set_ca_paths | |
. configure_ca | |
. create_environment | |
set-location $START_LOCATION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment