Windowsスクリプトと手順

この項のスクリプトをコピーすることにより、input.propertiesおよびskip_update.ps1を作成します。

  1. 次のスクリプトをコピーすることにより、input.propertiesを作成します:
    username=exampleAdmin
    password=examplePassword.epw
    url=exampleURL
    updatemonths=02,05,08,11
    
  2. パラメータ値を指定して、input.propertiesを更新します。

    Table 3-11 input.propertiesのパラメータ

    パラメータ 説明
    username サービス管理者のユーザー名
    password サービス管理者のパスワードまたは暗号化されたパスワード・ファイルの名前と場所。
    url 月次以外の更新頻度を設定する環境のURL。
    updatemonths Oracle Enterprise Performance Management Cloudの更新時のurlパラメータで識別される環境に適用する必要がある月のカンマ区切りリスト。例: updatemonths=02,05,08,11

    月は2桁で指定する必要があります(1月の01から12月の12まで)。1月から9月までは、先頭にゼロを付けてください。スクリプトは、updatemonthsパラメータ値に含まれない月に対して、skipUpdateコマンドを実行します。たとえば、updatemonths=02,05,08,11と指定すると、スクリプトは更新のスキップ・フラグを1月、3月、4月、6月、7月、9月、10月および12月に設定するため、2月、5月、8月および11月にのみ更新が行われます。

  3. 次のスクリプトをコピーすることにより、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