Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
nathanbell
Contributor
Contributor

Replicate .NET API Resume Task in Powershell

Import-Module Attunity -Force

$aemHostName = "REDACTED"
$plaincred = Get-AttunityUserInfo -ServerInstance REDACTED -Databasename REDACTED

$pw = $plaincred.UserPW
$uname = $plaincred.UserID

$password = ConvertTo-SecureString $pw -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($uname, $password)

$client = Get-AttunityClient -Credential $Cred -aemHost $aemHostName

# Set variable to hold one or more replicate servers
$replservers = @()

# Return one or more replicate servers only from "Production"
$replservers += $client.GetServerList().ServerList | Where-Object {$_.Description -like "*Prod*"}

foreach ($server in $replservers)
{

    # Get the task list for the first replicate server
    $taskList = $client.GetTaskList($server.Name)
    $taskLatencies = @()


    Add-Type -path "C:\Program Files\WindowsPowerShell\Modules\Attunity\0.0.4\aem\clients\dotnet\AemRestClient.dll"
    $options = New-Object Attunity.Aem.RestClient.Models.AemRunTaskOptions

    foreach ($task in $taskList.TaskList) {
        $taskDetails = $client.GetTaskDetails($replservers[0].Name, $task.Name)
        $taskLatencies += $taskDetails | Select-Object Name,@{Name="TotalLatency"; Expression={$_.CDCLatency.TotalLatency}}
        if ($task.Name -eq "SQL_RELYENCE") {
            
            Write-Host "STOPPING TASK $($task.Name)"
            $client.StopTask($server.Name, $task.Name,30)
            

            Write-Host "STARTING TASK $($task.Name)"
            # Use the correct AemRunTaskOptions enum for RESUME_PROCESSING
            $option= $options::RESUME_PROCESSING
            # Run the task with the correct option
            $client.RunTask($server.Name, $task.Name,$option)

    }
}

}

# Use the correct AemRunTaskOptions enum for RESUME_PROCESSING
$option= $options::RESUME_PROCESSING
# Run the task with the correct option
$client.RunTask($server.Name, $task.Name,$option)

 

The above snippet in .NET we are trying to resume the tack but getting the following error:

Cannot find an overload for "RunTask" and the argument count: "3".
At C:\Users\bh48250_a\Documents\powershell\GetAEMData.ps1:44 char:13
+ $client.RunTask($server.Name, $task.Name,$option)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest

The sdk reference for RunTask() is as follows:

 

RunTask | Qlik Enterprise Manager Help

 

I am looking to just resume processing on a task via the API.  documentation says that the 

 

Syntax

public AemRunTaskResp RunTask(

AemRunTaskReq payload,

string server,

string task,

AemRunTaskOptions option = AemRunTaskOptions.Option,

int timeout = 30

);

 

I the payload for AemRunTaskReq looks like it shouldnt be required for resume processing.  Looking for a decent example of resuming a task via .net API

 

Labels (1)
  • APIs

2 Replies
OritA
Support
Support

Hi , 

Could you please open a SalesForce case for your issue and attach to the case the details + the script you are using so that support team will be able to review it and see if there is any issue with it. 

Thanks & regards,

Orit

nathanbell
Contributor
Contributor
Author

I will get a case opened but for one reason or another the REST method works just fine:

 

https://{host}/attunityenterprisemanager/api/v1/servers/{ServerName}/tasks/{TaskName}?action=run&option=RESUME_PROCESSING