Hi
one option to use your Runbook up to "Query Database" Activity
Flatten your "Query Database" Activity using line breaks.
Use the PowerShell Code below in a "Run .Net Script" Activity. Instead of the text from your example subscripe the result your "Query Database" Activity.
$QueryResult = @'
SRV001;2021-02 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4601318);Required;Server - Updates - Current Month;4601318
SRV001;Microsoft Edge-Stable Channel Version 88 Update for x64 based Editions (Build 88.0.705.63);Required;Server - Updates - Current Month;
SRV002;2021-02 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4601318);Required;Server - Updates - Current Month;4601318
SRV002;Microsoft Edge-Stable Channel Version 88 Update for x64 based Editions (Build 88.0.705.63);Required;Server - Updates - Current Month;
'@
$ResultInArray = $QueryResult.Split([Environment]::NewLine) | where {$_ -ne ''}
$ServerNames = @()
foreach ($item in $ResultInArray) {
$ServerNames += ($item.Split(';'))[0]
}
$ServerNames = $ServerNames | select -Unique
$Server4Ticket = @()
$Text4Ticket = @()
foreach ($ServerName in $ServerNames) {
$Server4Ticket += $ServerName
$Text4Server = ''
foreach ($line in $ResultInArray) {
if (($line.Split(';'))[0] -eq $ServerName) {
$Text4Server = $Text4Server + ($line.Split(';'))[1] + [Environment]::NewLine
}
}
$Text4Ticket += $Text4Server
}
Publish Server4Ticket and Text4Ticket in the "Run .Net Script" Activity.
Regards,
Stefan