-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.ps1
53 lines (45 loc) · 1.43 KB
/
parser.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Function ParsePu ($stdout) {
$rootPDS = @{}
$headerLineLength = 8
$PPDSName = $null
$CurrentPDS = $null
$lineCount = 0
foreach ($line in $stdout) {
if (($line -ne "") -and ($lineCount -gt $headerLineLength)) {
$varName, $varType, $varLength, $varValue = $line.Split(" ").Where({ "" -ne $_ })
# Skip this row
if ($varName -eq "~") {
continue
}
if (($varType -eq "PDS_PCH") -or ($varType -eq "PDS_I")) {
if ($null -ne $CurrentPDS) {
if ($null -ne $PPDSName) {
}
else {
$rootPDS[$CurrentPDS].Add($varName, $varValue)
}
}
else {
$rootPDS.Add($varName, $varValue)
}
}
elseif ($varType -eq "PDS_PPDS") {
$PPDSName = $varName
$rootPDS.Add($varName, @())
}
elseif ($varType -eq "PDS_PDS") {
$CurrentPDS = $varName
if ($null -eq $PPDSName) {
$rootPDS.Add($varName, @{})
}
else {
}
}
}
$lineCount++
}
$rootPDS
}
$stdout = Get-Content "./stdout.txt"
$result = ParsePu $stdout
Write-Host $result["OsVersion"]