通过复制本节中的脚本,创建 input.properties
和 skip_update.ps1
。
input.properties
:
username=exampleAdmin password=examplePassword.epw url=exampleURL updatemonths=02,05,08,11
input.properties
。
Table 3-11 input.properties 参数
参数 | 说明 |
---|---|
username |
服务管理员的用户名。 |
password |
服务管理员的密码或加密密码文件的名称和位置。 |
url |
更新节奏要设置为不是每月一次的环境的 URL。 |
updatemonths |
应将 Oracle Enterprise Performance Management Cloud 更新应用于 url 参数所标识环境的月份的逗号分隔列表。例如,updatemonths=02,05,08,11 。
月份必须指定为两位数字:01 表示一月,12 表示十二月。确保一月到九月的数字包含前面的零。该脚本尝试为没有包含在 |
skip_updates.ps1
:
# Skip Update PowerShell script $inputproperties = ConvertFrom-StringData(Get-Content ./input.properties -raw) $username="$($inputproperties.username)" $password="$($inputproperties.password)" $url="$($inputproperties.url)" $updatemonths="$($inputproperties.updatemonths)" $monthsarr = ("01","02","03","04","05","06","07","08","09","10","11","12") $global:monthsarrfromcurrent = @() $global:yearsarrfromcurrent = @() $updatemonthsarr = $updatemonths.Split(",") $currentyear=Get-Date -Format yy $currentmonth=Get-Date -Format MM $nextyear=[int]$currentyear+1 function populateFromCurrentArrays() { $startposition = 0 for ($i = 0; $i -le ($monthsarr.length - 1); $i++) { if (${currentmonth} -eq $monthsarr[$i]) { $startposition=$i break } } for ($i = 0; $i -le ($monthsarr.length - 1); $i++) { if (${i} -ge ${startposition}) { $global:monthsarrfromcurrent += $monthsarr[$i] $global:yearsarrfromcurrent += $currentyear } } for ($i = 0; $i -le ($monthsarr.length - 1); $i++) { if (${i} -lt ${startposition}) { $global:monthsarrfromcurrent += $monthsarr[$i] $global:yearsarrfromcurrent += $nextyear } } } function skipUpdateAdd($yearnumber, $monthnumber) { echo "Running: epmautomate.bat skipUpdate add version=${yearnumber}.${monthnumber} comment=`"adding skipUpdate`"" epmautomate skipUpdate add version=${yearnumber}.${monthnumber} comment="adding skipUpdate" } function processSkipUpdates() { $addcount = 0 echo "Running: epmautomate.bat login ${username} ${password} ${url}" epmautomate login ${username} ${password} ${url} echo "Running: epmautomate.bat skipUpdate remove" epmautomate skipUpdate remove for ($i = 0; $i -le ($global:monthsarrfromcurrent.length - 1); $i++) { $match = 1 if (${addcount} -eq 2) { echo "Two skip update add calls have been made. No more will be attempted." break } for ($j = 0; $j -le ($updatemonthsarr.length - 1); $j++) { if ($global:monthsarrfromcurrent[$i] -eq $updatemonthsarr[$j]) { $match = 0 break } } if (${match} -eq 1) { skipUpdateAdd $global:yearsarrfromcurrent[$i] $global:monthsarrfromcurrent[$i] $addcount += 1 } } echo "Running: epmautomate.bat skipUpdate list" epmautomate skipUpdate list echo "Running: epmautomate.bat logout" epmautomate logout } function compareUpdateMonths($thismonth, $nextmonth) { $nextmonthorig=${nextmonth} if (${nextmonth} -lt ${thismonth}) { $nextmonth+=12 } $monthdiff = $nextmonth - $thismonth if (${monthdiff} -gt 3) { echo "There are more than 2 months skipped from month ${thismonth} to month ${nextmonthorig}. Please correct updatemonths in input.properties so that there are not more than two months skipped between each update month. Exiting." exit 1 } } function validateUpdateMonths() { for ($i = 0; $i -le ($updatemonthsarr.length - 1); $i++) { $nextint = $i + 1 $thisupdatemonth = $updatemonthsarr[$i] $thisupdatemonthint=[int]$thisupdatemonth $nextupdatemonth=$updatemonthsarr[$nextint] $nextupdatemonthint=[int]$nextupdatemonth if (${nextupdatemonth} -eq "") { $nextupdatemonth=$updatemonthsarr[0] $nextupdatemonthint=[int]$nextupdatemonth } compareUpdateMonths $thisupdatemonthint $nextupdatemonthint } } validateUpdateMonths populateFromCurrentArrays processSkipUpdates