суббота, 28 ноября 2020 г.

BluePrism AutmateC.exe PowerShell Automation

 


Load the Queues

    $automatec = "C:\Program Files\Blue Prism Limited\Blue Prism Automate\AutomateC.exe"

    & $automatec /sso /startschedule /schedule "03.01 - Load AUH SCAL Queue" #577

    & $automatec /sso /startschedule /schedule "03.03 - Load PDR SCAL Queue" #575

    & $automatec /sso /startschedule /schedule "03.04 - Load PDR NCAL Queue" #574

    & $automatec /sso /startschedule /schedule "03.05 - Load AUH NW Queue" #563

    & $automatec /sso /startschedule /schedule "03.06 - Load PDR GA Queue" #570


Logout, Login, BotStart

# === Clean PowerShell ===

$ps = [PowerShell]::Create()

$ps.AddScript('Get-Variable | Select-Object -ExpandProperty Name') | Out-Null

$builtIn = $ps.Invoke()

$ps.Dispose()

$builtIn += "profile","psISE","psUnsupportedConsoleApplications" # keep some ISE-specific stuff


Remove-Variable (Get-Variable | Select-Object -ExpandProperty Name | Where-Object {$builtIn -NotContains $_})

# ======================

Function ShortLogoutLogin {

[CmdletBinding()]

Param($j)

    $h = $j + ":9003"

    Write-Host $j 

    Logout -VmName $h

    Login -VmName $j

}

Function Logout {

[CmdletBinding()]

Param($VmName)

    Write-Host "Execute LOGOUT ..."

    & $automatec /run $logout_process /resource $VmName /sso

    Start-Sleep -s 0

}

Function Login {

[CmdletBinding()]

Param($VmName)

    Write-Host "Execute LOGIN..."

    & $automatec /run $login_process /resource $VmName /sso /startp "<inputs><input name='Login Locally' type ='Flag' value='False' /><input name='Domain' type ='Text' value='cs' /><input name='Send Secure Attention Sequence' type ='Flag' value='True' /></inputs>"

    Start-Sleep -s 0

}

Function StartBot {

[CmdletBinding()]

Param($VmName, $BotName)

    $BotParams=$BotParamsMap[$BotName]

    & $automatec /run $BotName /resource $VmName /sso /startp $BotParams

    Start-Sleep -s 0

}

# ======================

$automatec = "C:\Program Files\Blue Prism Limited\Blue Prism Automate\AutomateC.exe"

#$automate = "C:\Program Files\Blue Prism Limited\Blue Prism Automate\Automate.exe"

$SCAL_AUH = "W10_Tap_SCAL_A02_MainProcess_Run_AUH"

$SCAL_PDR = "W10_Tap_SCAL_A01_MainProcess_Run_PDR"

$login_process = "Login"

$logout_process = "Logout"

$VmPrefix = "MASDCVDI000"

#$Sessions = @()

$BotParamsMap = @{"W10_Tap_SCAL_A02_MainProcess_Run_AUH"="<inputs><input name='Test Mode' type ='Flag' value='False' /></inputs>"

          "W10_Tap_SCAL_A01_MainProcess_Run_PDR"="<inputs><input name='Test Mode' type ='Flag' value='False' /></inputs>"

          "W10_Tap_NCAL_A01_MainProcess_Run_PDR"="<inputs><input name='Test Mode' type ='Flag' value='False' /></inputs>"

          "W10_Tap_GA_A01_MainProcess_Run_PDR"="<inputs><input name='Test Mode' type ='Flag' value='False' /></inputs>"

         }

$BotNames= @("W10_Tap_SCAL_A02_MainProcess_Run_AUH",

            "W10_Tap_SCAL_A01_MainProcess_Run_PDR",

            "W10_Tap_NCAL_A01_MainProcess_Run_PDR",

            "W10_Tap_GA_A01_MainProcess_Run_PDR"

            )

For($i = 0; $i -lt $BotNames.Count; $i++){

    Write-Host $i ": "$BotNames[$i]

}

$BotIndex = Read-Host 'Enter name ofJobIndex:'


$Task = $BotNames[$BotIndex]

Write-Host $Task


$VM_except = @(560,561,562,564,565,566,568,569,570,578)

#$VM_except_flag = $true

$VM_except_flag = $false

$VM_Start = 554

$VM_End = 578

# === Loop Logout

For ($i = $VM_Start; $i -le $VM_End; $i++) {

    $j = $VmPrefix + $i

    $h = $j + ":9003"

    if ($VM_except_flag) {

        if (-Not ($VM_except.Contains($i))) {

            Logout -VmName $h

        }

    }

    else {

        if ($VM_except.Contains($i)) {

            Logout -VmName $h

        }

    }

}

# === Loop Login

For ($i = $VM_Start; $i -le $VM_End; $i++) {

    $j = $VmPrefix + $i

    $h = $j + ":9003"

    if ($VM_except_flag) {

        if (-Not ($VM_except.Contains($i))) {

            Login -VmName $j

        }

    }

    else {

        if ($VM_except.Contains($i)) {

            Login -VmName $j

        }

    }

}

# === Loop BotRun

For ($i = $VM_Start; $i -le $VM_End; $i++) {

    $j = $VmPrefix + $i

    $h = $j + ":9003"

    if ($VM_except_flag) {

        if (-Not ($VM_except.Contains($i))) {

            StartBot -VmName $h -BotName $Task

        }

    }

    else {

        if ($VM_except.Contains($i)) {

            StartBot -VmName $h -BotName $Task

        }

    }

}

Комментариев нет:

Отправить комментарий