Here’s a script to trigger an EDX task from Powershell. As it is, you will need to change QVSERVER to match your server name. The script can then be run from the command line by passing the task name and EDX password as parameters.
Download the QlikView EDX Trigger in Powershell. Do not copy and paste the code below.
param($taskName,$taskEDXPassword)
function QVPOST([string]$updateurl, [string]$text)
{
$result = $null
[System.Net.HttpWebRequest] $request = [System.Net.HttpWebRequest] [System.Net.WebRequest]::Create($updateurl)
$request.UseDefaultCredentials = $true
$request.Method = "POST"
$request.ContentType = "application/x-www-form-urlencoded"
$request.ContentLength = $text.Length
[System.IO.StreamWriter] $stOut = new-object System.IO.StreamWriter($request.GetRequestStream(), [System.Text.Encoding]::ASCII)
$stOut.Write($text)
$stOut.Close()
[System.Net.HttpWebResponse] $response = [System.Net.HttpWebResponse] $request.GetResponse()
if ($response.StatusCode -ne 200)
{
$result = "Error : " + $response.StatusCode + " : " + $response.StatusDescription
}
else
{
$sr = New-Object System.IO.StreamReader($response.GetResponseStream())
$result = $sr.ReadToEnd()
}
return $result
}
1$response = 1(QVPOST "http://QVSERVER:4720/qtxs.asmx" "<Global method=`"GetTimeLimitedRequestKey`" />")
$requestKey = $response.GetTimeLimitedRequestKey.GetTimeLimitedRequestKeyResult
$taskEDXRequest=@"
<Global method="RequestEDX" key="$($requestKey)">
<i_TaskIDOrTaskName>$($taskName)</i_TaskIDOrTaskName>
<i_Password>$($taskEDXPassword)</i_Password>
<i_VariableName />
<i_VariableValueList />
</Global>
"@
$response = QVPOST "http://QVSERVER:4720/qtxs.asmx" $taskEDXRequest
echo $response.RequestEDX.RequestEDXResult
Related posts:
Pingback: Diigo bookmarks 04/01/2011 (a.m.) @countnazgul.com
Nice, thanks!
Regards
Stefan
Hello,
I was trying your script but it doesn’t work, the number 1 on line 30 gives error.
I’ve tried to remove but the $requestKey never gets a value.
Thank you very much,
Pedro
Thank you. I have had a lot of trouble with the code format plugin. Please use the new download link. I added a ZIP file with the correct code.