Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I am trying to export task using export rest api but not able to export task using powershell.
I am trying to with the below command using powershell
$ExportResponse = Invoke-RestMethod -uri "https://qlikmanagerlab.cnppd.lab/attunityenterprisemanager/api/v1/servers/qlikreplicatelab/tasks/CIC..." -Headers $export_headers -Method 'GET' | ConvertTo-JSON | Set-Content "C:\Users\xt28034\Documents\sample1.json"
$outputfile = $ExportResponse | ConvertTo-JSON
Write-Output $outputfile
=============================================
I am not able to get the output while executing the above command. please help me on this
Well,
The documentation (Enterprise Manager API Guide) shows the output is "JSON File (stream)", not an object to be converted to json.
I encourage you to use babysteps. Get the output from the method into a variable. Do a get-member to see what it looks like. Next pipe the variable into a file. See what the file looks like (make sure it is ASCII - the default Encoding for Set-Content.
Personally I prefer the "Enterprise Manager .NET API" as is seems more natural to the Powershell environment to me: $json = $client.ExportTask("localhost","testtaskname")
$AemServer = 'localhost' # change AEM server location as need be
$AemURL = "https://" + $AemServer + "/attunityenterprisemanager"
$AemUserName = $env:UserDomain + '\' + $env:UserName
$dll = 'C:\Program Files\Attunity\Enterprise Manager\clients\dotnet\AemRestClient.dll' # QEM ??
Import-Module $dll # point to DLL. actual location or copy.
$credential = Get-Credential -Credential $AemUserName
$client = New-Object Attunity.Aem.RestClient.AemRestClient($Credential, $AemURL, $false)
$client # Display
if (-not $client) { return } # Did we get a useable client object ?
$client | Get-Member # Show all available methods.
$json = $client.ExportTask("localhost","sql_2_sql")
$json | Set-Content x.json
Well,
The documentation (Enterprise Manager API Guide) shows the output is "JSON File (stream)", not an object to be converted to json.
I encourage you to use babysteps. Get the output from the method into a variable. Do a get-member to see what it looks like. Next pipe the variable into a file. See what the file looks like (make sure it is ASCII - the default Encoding for Set-Content.
Personally I prefer the "Enterprise Manager .NET API" as is seems more natural to the Powershell environment to me: $json = $client.ExportTask("localhost","testtaskname")
$AemServer = 'localhost' # change AEM server location as need be
$AemURL = "https://" + $AemServer + "/attunityenterprisemanager"
$AemUserName = $env:UserDomain + '\' + $env:UserName
$dll = 'C:\Program Files\Attunity\Enterprise Manager\clients\dotnet\AemRestClient.dll' # QEM ??
Import-Module $dll # point to DLL. actual location or copy.
$credential = Get-Credential -Credential $AemUserName
$client = New-Object Attunity.Aem.RestClient.AemRestClient($Credential, $AemURL, $false)
$client # Display
if (-not $client) { return } # Did we get a useable client object ?
$client | Get-Member # Show all available methods.
$json = $client.ExportTask("localhost","sql_2_sql")
$json | Set-Content x.json
Suresh, you wrote only: "Please help me with the command to run the export task using powershell."
That's a very dissapointing reply from a professional in the context of the earlier question and answer.
Please up your game! Specially with respect to the basic skill of good question asking.
A fairly complete answer was given. If you have problems with that, indicate specifics.
Guidance was given on how to you might solve your challenge. Please indicate the efforts you put into that and what the outcome was.
btw, One way to run an export task from command shell or Powershell, on a Replicate server, is to simply use the REPCTL EXPORTREPOSITORY command which is documented in the Replicate Userguide.
Also, What problem are you ultimately trying to solve, what is the purpose of the export? Maybe there are better ways.
Hein.
Unbelievable! You are still not providing pertinent information to help us help you.
We are not psychic! Share with us EXACTLY what you you expected, EXACTLY what you tried, and EXACTLY what was the result, preferably EXACTLY highlighting what the issue with that was if not very obvious (like and error).
And please re-read the first reply carefully and apply it!
Please go do your homework before asking again.
Regards,
Hein
@rsuresh did you figure it out?
Inquiring minds would like to know. Perhaps you can share your problem/solution to help others?
Thanks,
Hein