Created
May 5, 2023 14:59
-
-
Save iversond/69b36b48e0f9409ff8ac8a5af1b63888 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]$DATABASE, | |
[Parameter(Mandatory=$true)][String]$PT_VERSION, | |
[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" | |
$DATABASE=$DATABASE.toUpper() | |
function get_patch_name { | |
$PATCH_NAME = "PATCH" + $PT_VERSION.replace(".","") | |
} | |
function apply_ptp_project { | |
Set-Location $CA_PATH | |
Write-Host "[${computername}][Task] Starting new PeopleTools Upgrade job for ${DATABASE}" | |
.\changeassistant.bat -MODE UM -ACTION PTPAPPLY -TGTENV $DATABASE -UPD $PATCH_NAME -OUT c:\temp\$DATABASE-ptp-start.log -WARNINGSOK Y -EXONERR Y | |
Write-Host "${tab}Change Assistant Exit Code: ${LASTEXITCODE}" | |
switch ($LASTEXITCODE) { | |
0 { | |
Write-Output "[${computername}][Complete] Change Assistant reported no more steps to run." | |
Exit 0 | |
} | |
1 { | |
Write-Error "[${computername}][Error] Error in PeopleTools upgrade job. Open Change Assistant to review the error." | |
Write-Host "${tab}Command to open CA: set-location '${CA_PATH}'; .\changeassistant.bat" | |
Write-Host "${tab}Error on Step: `n`t" ${STEP} "(" ")" | |
Set-Location $START_LOCATION | |
Exit 1 | |
} | |
2 { | |
# Add Code in here to capture the CA output, determine the manual stop, and handle appropriately | |
# For now, continue for a vanilla upgrade | |
Write-Host "[${computername}][Manual Task] Manual Stop Encountered" | |
Set-Location $START_LOCATION | |
Exit 2 | |
} | |
3 { | |
Write-Error "[${computername}][Error] Change Assistant failed to get a lock on the environment." | |
Write-Host "${tab}Command to open CA: set-location '${CA_PATH}'; .\changeassistant.bat" | |
Set-Location $START_LOCATION | |
Exit 3 | |
} | |
Default { | |
Write-Error "[${computername}][Error] Unknown Error Occured. Exiting." | |
Write-Host "${tab}Command to open CA: set-location '${CA_PATH}'; .\changeassistant.bat" | |
Set-Location $START_LOCATION | |
Exit 4 | |
} | |
} | |
} | |
#------------------------------------------------------------[Main]---------------------------------------------------------- | |
$START_LOCATION = get-location | |
. get_patch_name | |
. apply_ptp_project | |
set-location $START_LOCATION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment