Skip to content

Instantly share code, notes, and snippets.

@iversond
Last active May 4, 2024 04:42
Show Gist options
  • Save iversond/b7c77fb5dcd8d2af3c7925ddc838cb3a to your computer and use it in GitHub Desktop.
Save iversond/b7c77fb5dcd8d2af3c7925ddc838cb3a to your computer and use it in GitHub Desktop.
Sample script to apply PATCH861 to database silently
#$env:PS_HOME='c:\PT8.61.02_Client_ORA'
$env:PS_HOME='c:\PT8.61.03_Client_ORA'
$env:PT_REL='8'
$env:PT_VER='61'
$env:ORACLE_HOME='C:\psft\pt\oracle-client\19.3.0.0'
$env:DB="FSCMCON"
# $env:PSCADBG="true"
$env:PATH="${env:PS_HOME}\bin\client\winx86;${env:PATH}"
$CA_BASE='c:\ca'
$CA_PATH='C:\Program Files\PeopleSoft\Change Assistant'
$ErrorActionPreference = "Stop"
$DebugPreference = "SilentlyContinue"
$VerbosePreference = "SilentlyContinue"
function set_ca_paths {
Write-Output " `n"
Write-Output "---------------"
Write-Output "Create CA Paths"
Write-Output "---------------"
Write-Output " `n"
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 " "
Write-Output "--------------------------"
Write-Output "Configure Change Assistant"
Write-Output "--------------------------"
Write-Output " "
set-location ${CA_PATH}
& "${CA_PATH}\changeassistant.bat" `
-MODE UM -ACTION OPTIONS `
-OUT "${CA_BASE}\output\ca.log" `
-REPLACE Y `
-EXONERR Y `
-SWP False `
-MCP 5 `
-PSH "${env:PS_HOME}" `
-STG "${CA_BASE}\staging" `
-OD "${CA_BASE}\output" `
-DL "${CA_BASE}\download" `
-SQH "${env:ORACLE_HOME}\bin\sqlplus.exe" `
-EMYN N `
-SRCYN N
if (!($LASTEXITCODE -eq 0)) {
Write-Error " x Error setting Change Assistant General Options."
Set-Location $START_LOC
Exit 1
}
}
function create_target_env {
Write-Output " "
Write-Output "--------------------------------------------"
Write-Output "Create Change Assistant Environment: FSCMCON"
Write-Output "--------------------------------------------"
Write-Output " "
set-location ${CA_PATH}
& "${CA_PATH}\changeassistant.bat" `
-MODE UM `
-ACTION ENVCREATE `
-TGTENV ${env:DB} `
-CT 2 `
-CA SYSADM `
-CAP SYSADM `
-CO VP1 `
-CP PS `
-CI people `
-CW peop1e `
-SQH ${env:ORACLE_HOME}\bin\sqlplus.exe `
-PSH ${env:PS_HOME} `
-PAH ${env:PS_HOME} `
-PCH ${env:PS_HOME} `
-SQRF "'-ZIF${env:PS_HOME}\sqr\pssqr.ini'"
if (!($LASTEXITCODE -eq 0)) {
Write-Error " x Error configuring Change Assistant. Check database name: [${env:DB}] (did you use upper case?)"
Set-Location $START_LOC
Exit 1
}
# Write-Output " `n"
# Write-Output "Set new PS_HOME: ${env:PS_HOME}"
# Write-Output " `n"
# .\changeassistant.bat -MODE UM -ACTION ENVUPDATE `
# -TGTENV ${env:DB} `
# -PSH ${env:PS_HOME} `
# -SQRF "'-ZIF${env:PS_HOME}\sqr\pssqr.ini'"
}
function truncate_ppm_tables {
Write-Output " "
Write-Output "--------------------"
Write-Output "Trunctate PPM Tables"
Write-Output "--------------------"
Write-Output " "
echo 'truncate table pspmagent;' | sqlplus SYSADM/SYSADM@${env:DB}
}
function apply_ptp {
Write-Output " "
Write-Output "-------------------------"
Write-Output "Apply PATCH${env:PT_REL}${env:PT_VER} to ${env:DB}"
Write-Output "-------------------------"
Write-Output " "
set-location ${CA_PATH}
& "${CA_PATH}\changeassistant.bat" `
-MODE UM `
-ACTION PTPAPPLY `
-UPD PATCH${env:PT_REL}${env:PT_VER} `
-TGTENV ${env:DB}
if (!($LASTEXITCODE -eq 0)) {
Write-Error " x Error configuring Change Assistant. Error applying PATCH${env:PT_REL}${env:PT_VER} to ${env:DB}"
Set-Location $START_LOC
Exit 1
} else {
truncate_ppm_tables
Write-Output "`n`n`n`n"
Write-Output "-------------------------------------------"
Write-Output " $([char]0x2605) PATCH${env:PT_REL}${env:PT_VER} successfully applied to ${env:DB}"
Write-Output "-------------------------------------------"
}
}
# ----- Main -----
$START_LOC="$(pwd)"
set_ca_paths
configure_ca
create_target_env
apply_ptp
set-location $START_LOC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment