Merge pull request #598 from bwuch/master

Updating module to resolve duplicate object bug
This commit is contained in:
kamennikolov
2022-12-21 10:47:56 +02:00
committed by GitHub
2 changed files with 3 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause
RootModule = 'VMware.Skyline.InsightsApi.psm1' RootModule = 'VMware.Skyline.InsightsApi.psm1'
# Version number of this module. # Version number of this module.
ModuleVersion = '1.0.0' ModuleVersion = '1.0.1'
# Supported PSEditions # Supported PSEditions
# CompatiblePSEditions = @() # CompatiblePSEditions = @()

View File

@@ -237,10 +237,9 @@ Function Get-SkylineFinding {
# Try to get results the first time # Try to get results the first time
$results = @() $results = @()
$thisQueryBody = $queryBody -Replace 'filter: {}', "filter: { $filterString }"
$thisIteration = 0 $thisIteration = 0
do { do {
$thisQueryBody = $thisQueryBody -Replace 'start: 0', "start: $thisIteration" $thisQueryBody = $queryBody -Replace 'filter: {}', "filter: { $filterString }" -Replace 'start: 0', "start: $thisIteration"
Write-Debug $thisQueryBody Write-Debug $thisQueryBody
$thisResult = Invoke-SkylineInsightsApi -queryBody (@{'query' = $thisQueryBody} | ConvertTo-Json -Compress) $thisResult = Invoke-SkylineInsightsApi -queryBody (@{'query' = $thisQueryBody} | ConvertTo-Json -Compress)
$totalRecords = $thisResult.data.activeFindings.totalRecords $totalRecords = $thisResult.data.activeFindings.totalRecords
@@ -325,13 +324,11 @@ Function Get-SkylineAffectedObject {
} }
process { process {
$thisQueryBody = $queryBody -Replace 'findingId: "",', "findingId: `"$findingId`","
foreach ( $thisProduct in $products ) { foreach ( $thisProduct in $products ) {
$thisIteration = 0 $thisIteration = 0
$results = @() # reset results variable between products $results = @() # reset results variable between products
do { do {
$thisQueryBody = $thisQueryBody -Replace 'product: "",', "product: `"$thisProduct`"," $thisQueryBody = $queryBody -Replace 'product: "",', "product: `"$thisProduct`"," -Replace 'start: 0', "start: $thisIteration" -Replace 'findingId: "",', "findingId: `"$findingId`","
$thisQueryBody = $thisQueryBody -Replace 'start: 0', "start: $thisIteration"
Write-Debug $thisQueryBody Write-Debug $thisQueryBody
$thisResult = Invoke-SkylineInsightsApi -queryBody (@{'query' = $thisQueryBody} | ConvertTo-Json -Compress) $thisResult = Invoke-SkylineInsightsApi -queryBody (@{'query' = $thisQueryBody} | ConvertTo-Json -Compress)
$totalRecords = $thisResult.data.activeFindings.Findings.totalAffectedObjectsCount $totalRecords = $thisResult.data.activeFindings.Findings.totalAffectedObjectsCount