From 49a6f65a768e174f3ab3b4111823784c894ad7e3 Mon Sep 17 00:00:00 2001 From: Karl-Wilfried Zimmer Date: Fri, 9 Feb 2024 00:06:14 +0100 Subject: [PATCH] PrintAffected to GetAffected, will now only print to screen in switch verbose is given --- Extractor.ps1 | 12 ++++++++++-- tests/extractortest malformed fail.txt | 12 +++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Extractor.ps1 b/Extractor.ps1 index f16044a..719ee3a 100644 --- a/Extractor.ps1 +++ b/Extractor.ps1 @@ -140,11 +140,19 @@ function buildIntervals { function PrintAffected { param ( $listOfIntervals, - [datetime]$point + [datetime]$point, + [switch] $verbose ) + $array = @() foreach ($elem in $listOfIntervals){ if ($point -le $elem.ending -and $point -ge $elem.begining){ - Write-Host "$point : $($elem.vm) $($elem.state)" + if ($verbose) { + Write-Host "$point : $($elem.vm) $($elem.state)" + } + if(!$array.Contains($elem.vm)){ + $array += @($elem.vm) + } } } + return $array } \ No newline at end of file diff --git a/tests/extractortest malformed fail.txt b/tests/extractortest malformed fail.txt index 9a78cde..3ce17ca 100644 --- a/tests/extractortest malformed fail.txt +++ b/tests/extractortest malformed fail.txt @@ -12,4 +12,14 @@ snrdaoeisnrdaoie:2024-02-06 20:00:00 some harddrive operation snrdaoeisnrdaoie:2024-02-06 20:00:00 some other Harddrive operation snrdaoeisnrdaoie: VMware-Maschine 'test2' snrdaoeisnrdaoie:aoei aoei VMware-Maschine 'test2' -snrdaoeisnrdaoie:2024-02-06 21:00:00 VMware-Maschine 'test2' \ No newline at end of file +snrdaoeisnrdaoie:2024-02-06 21:00:00 VMware-Maschine 'test2' + +snrdaoeisnrdaoie:2024-02-06 20:00:00 gestartet VMware-Maschine 'test' +snrdaoeisnrdaoie:2024-02-06 20:00:00 gestartet VMware-Maschine 'test' +snrdaoeisnrdaoie:2024-02-06 20:00:00 some harddrive operation +nsriadoeisnrdaoei +snrdaoeisnrdaoie:2024-02-06 20:00:00 some other Harddrive operation +snrdaoeisnrdaoie:2024-02-06 20:01:00 VMware-Maschine 'test' Erfolgreiche +snrdaoeisnrdaoie:2024-02-06 20:01:00 VMware-Maschine 'test' Erfolgreiche +snrdaoeisnrdaoie:2024-02-06 20:01:00 VMware-Maschine 'test' +snrdaoeisnrdaoie:2024-02-06 20:00:00 gestartet VMware-Maschine 'test2' \ No newline at end of file