From ef7e7b933b336f763b9a40d9460eded709cbdf2c Mon Sep 17 00:00:00 2001 From: Karl-Wilfried Zimmer Date: Thu, 8 Feb 2024 22:20:38 +0100 Subject: [PATCH] adde functions to allow unification of hashmap creation --- Extractor.ps1 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Extractor.ps1 b/Extractor.ps1 index 1d9ef52..b1b298a 100644 --- a/Extractor.ps1 +++ b/Extractor.ps1 @@ -65,9 +65,25 @@ foreach ($elem in $Elements){ $HashTable } -$lines = Get-Content -Path .\log.txt | ForEach-Object {$_.SubString($_.IndexOf(":")+1)} +function getElems { + param ( + $Path + ) + $lines = Get-Content -Path $Path | ForEach-Object {$_.SubString($_.IndexOf(":")+1)} + $elems = $lines | Out-String -Stream | Select-String -Pattern "VMware-Maschine" | Out-String -Stream + return $elems +} + +function ProcessLogToHash { + param ( + $Path + ) + ProduceHashMap -Elements $(getElems -Path $Path) +} + +<#$lines = Get-Content -Path .\log.txt | ForEach-Object {$_.SubString($_.IndexOf(":")+1)} $elems = $lines | Out-String -Stream | Select-String -Pattern "VMware-Maschine" | Out-String -Stream -ProduceHashMap($elems) +ProduceHashMap($elems)#> <#$HashTable =@{} foreach ($elem in $Elems){ $indexOfFirst = $elem.IndexOf(" ")