Invoke-KFUnstructuredDataEventSimulation
Syntax
Invoke-KFUnstructuredDataEventSimulation
-Body <http-request-body>
[-HttpMethod <method> (POST)]
[-QueryString <querystring> ($null)]
[-SimulatedUserName <username> (the current user)]
[-SimulatedUserPassword <password> ("123")]
[-MarkAsAuthenticated[:$true]]
[-Authentication <authentication-method> (Anonymous)]
[-OutputFormat <output-format> (None)]
[-ThrowErrors[:$true]]
Support
>= kenaflow 2.0.46
Return
An object of type kenaflow.EventDataSimResult
:
public class EventDataSimResult
{
public RemoteEventSource EventSource { get; set; }
public object EventData { get; set; }
public int OutputFormat { get; set; } = 0;
}
RemoteEventSource
will have the value Unstructured
for this cmdlet.
Description
This cmdlet is used to simulate a Remote Event to be able to debug workflow scripts in the event execution context.
Please read Debugging and Remote Event for details!
The cmdlet can only be used in a script block that is specified for parameter -EventData
of cmdlet Invoke-Kenaflow.
The return object of this cmdlet is used by Invoke-Kenaflow
to configure the runtime environment for kenaflow to execute the remote event.
Parameters
-Body <http-request-body>
The http request body as string. The data is passed to the workflow script as part of the
$eventData
object.
[-QueryString <querystring> ($null)]
This is the query portion of the URL that is passed to the workflow script as part of the
$eventData
object. If it is well formed (key1=value1&key2=value2&...
) it is split into key-value-pairs. Otherwise the script gets it as string.
[-HttpMethod <method> (POST)]
Here you can specify the http method. GET and POST are allowed. POST is default.
[-SimulatedUserName <username> (the current user)]
This is used to simulate an authenticated request. It is passed to the script as part of the
$eventData
object. It is only used in case of 'Basic' authentication. See parameter-Authentication
below. Default is the name of the current user.
[-SimulatedUserPassword <password> ("123")]
This is the simulated password for the authentication. Default is "123".
[-MarkAsAuthenticated[:$true]]
This can be used to simulate a not successful authenticated request. It is passed to the script as part of the
$eventData
object.
[-Authentication <authentication-method> (Anonymous)]
One of these values:
Anonymous
(default)NTML
Basic
In case of NTLM the current users credentials are used to simulate the request.
[-OutputFormat <output-format> (None)]
Unstrucuted data remote events can return data to the client. In the request simulation this return data is send to the calling script as return value of
Invoke-Kenaflow
. You can choose one of the following values.
None
(default): The workflow script does not return any data to the client.Unconverted
: The return data is not converted in any way. Its passed to the calling script as it is collected by kenaflow. This method is for debugging purpose only. To simulate "real" return data use one of the next two options.JsonString
: The return data is serialized to JSON as it would happen in a real http request.ClixmlString
: The return data is serialized to PowerShell CliXML as it would happen in a real http request.Binary
: The return data is written as pure bytes to the http response stream.
[-ThrowErrors[:$true]]
This is a default parameter for all kenaflow cmdlets. If set to
$true
(default!) the engine will pass exception within the cmdlet to the script for further handling.
Example
Import-Module "C:\Program Files\kenaflow\kenaflow.runtime.dll";
$output = Invoke-Kenaflow -Debug -EventData {
Invoke-KFUnstructuredDataEventSimulation -QueryString "test1&test2" -Body "test" `
-SimulatedUserName "sharepoint\ingo" -SimulatedUserPassword "kr@ftwerk" -Authentication Basic `
-OutputFormat Unconverted
}
$output.Test
$output.currentDate
$output.Evt
Example "Get-PDF"
When opening the URL in the browser you will see a live generated PDF.
_wfconfig.ps1
@{
Version = "2.0";
Enabled = $true;
Type = "POWERSHELL";
Name = "get-pdf";
Id = "7c24e165-21c2-418e-ab3e-c6702837b533";
TBE = -1;
ConfigListDefaults = @{
"kenaflow" = "cool"
};
AlertAddresses = @();
MailFrom = "";
MailReply = "";
Script = "script.ps1";
RER = $true;
}
if(!$kenaflow){import-module "D:\kenaflow\engine\kenaflow.runtime.dll";Test-KFConfig;exit}
script.ps1
param($wf, $eventData, $config)
if($wf-eq$null){import-module "D:\kenaflow\engine\kenaflow.runtime.dll";Invoke-Kenaflow;exit}
if($eventData) {
return (New-KFPDF -html "<html><body><h1>$([Datetime]::Now)</h1></body></html>")
}
test.bat
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "http://kenaflow20.sharepoint.farm/6070b29c-bfd3-4f58-9d21-3a444fa0f69b/uda/b/7c24e165-21c2-418e-ab3e-c6702837b533?__as=application/pdf"