ok, adding everything in the STDOUT and parsing on the VisualCron side is where I have focused the last couple days.
So I am using: {STRING(FirstLine|{TASK(072b4318-a6c1-4c00-890d-53cd8b14eba2,StdOut)})}
to get the "pass/fail" variable
But all my other information follows on a Row basis....or Line basis.
I think there is only firstline and lastline to key on with string filtering correct?
or can you do Line 4-->Lastline
or Line 6 to line 22 (for example)
Here is an example of my output:
34
True
Arrowhead
255
Count Name
----- ----
9 HOST250
3 HOST500
7 HostServer1
4 HostServer2
2 HostLaptop3
22 HostLaptop4
4 HostPC5
2367 HostPC6
I guess I could split them up into multiple PS scripts and then use each STDOUT separately as it's own variable as well, just a bit cumbersome.
In the Powershell task, format your table to return parse-able strings. Here is a script I wrote to do that using a JSON string input (if you aren't using JSON, you probably should modify that part of the script):
param(
[Parameter(Mandatory = $true)]
[string]$JsonFileIn
)
$jsonObj = (Get-Content $JsonFileIn) -join "`n" | ConvertFrom-Json
$columnNames = New-Object System.Collections.Generic.List[String]
$jobConfigurationsArray = $jsonObj.PSObject.Properties.Value
ForEach($jobConfigurationObject in $jobConfigurationsArray)
{
ForEach($property in $jobConfigurationObject.PsObject.Properties)
{
if ($property.Name -notin $columnNames)
{
$columnNames.Add($property.Name)
}
}
}
[string]$formatTableConfigString
$tableConfigurationsScriptArray = @()
ForEach($columnName in $columnNames)
{
$expressionString = "`"```"{0}```"```~`" -f `$_.$columnName"
$expression = [scriptblock]::Create($expressionString)
$hashtableNameScript = @{Name = "$columnName"; Expression = $expression}
$tableConfigurationsScriptArray += $hashtableNameScript
}
Write-Output $jobConfigurationsArray | Format-Table $tableConfigurationsScriptArray |Out-String -Width 8000
This'll return tilde separated, dbl quote qualified output that directly mirrors your table. Of course, that means it has the 2nd row with the dashes. Swap out the tilde in $expressionString = "`"```"{0}```"```~`" -f `$_.$columnName" with the delimiter of your choice. You can also remove the dbl quotes (with their three single quote escape characters) around the {0} to remove the dbl quote qualification. This script is/was a quick and dirty fix, so you might have to do some of your own work to get it working how you want.
If you do a "Set Job Variable Task" with the value {STRING(GetColumn|3|1|~|)} and another "Set Job Variable Task" with the value {STRING(GetColumn|3|2|~|)} you should get your "9" and "HOST250". If you slap a loop on top of it starting on row 3 (start on 2 as the loop array starts at zero), you can instead use {LOOP(CurrentValueXArray,0)} and {LOOP(CurrentValueXArray,1)} to get your values in each row out and set as job variables. At that point, you can put tasks within the loop that use those values. Of course, if you can't put it into a loop, you'd need to just set up 40ish "Set Job Variable Tasks" to extract all 2 values for each of the 20 variables.
Edited by user
2017-08-28T20:15:00Z
|
Reason: Not specified