internal/tepp/scripts/input.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
Register-PSFTeppScriptblock -Name PSFramework-Input-ObjectProperty -ScriptBlock {
    #region Utility Functions
    function Get-Property
    {
        [CmdletBinding()]
        param (
            $InputObject
        )
        
        if (-not $InputObject) { return @{ } }
        $properties = @{ }
        
        switch ($InputObject.GetType().FullName)
        {
            #region Variables or static input
            'System.Management.Automation.Language.CommandExpressionAst'
            {
                switch ($InputObject.Expression.GetType().Name)
                {
                    'BinaryExpressionAst'
                    {
                        # Return an empty array. A binary expression ast means pure numbers as input, no properties
                        return @{ }
                    }
                    'VariableExpressionAst'
                    {
                        $members = Get-Variable -Name $InputObject.Expression.VariablePath.UserPath -ValueOnly -ErrorAction Ignore | Write-Output | Select-Object -First 1 | Get-Member -MemberType Properties
                        foreach ($member in $members)
                        {
                            try
                            {
                                $typeString = $member.Definition.Split(" ")[0]
                                $memberType = [type]$typeString
                                $typeKnown = $true
                            }
                            catch
                            {
                                $memberType = $null
                                $typeKnown = $false
                            }
                            
                            $properties[$member.Name] = [pscustomobject]@{
                                Name = $member.Name
                                Type = $memberType
                                TypeKnown = $typeKnown
                            }
                        }
                        return $properties
                    }
                    'MemberExpressionAst'
                    {
                        try { $members = Get-Variable -Name $InputObject.Expression.Expression.VariablePath.UserPath -ValueOnly -ErrorAction Ignore | Where-Object $InputObject.Expression.Member.Value -ne $null | Select-Object -First 1 -ExpandProperty $InputObject.Expression.Member.Value -ErrorAction Ignore | Get-Member -MemberType Properties }
                        catch { return $properties }
                        foreach ($member in $members)
                        {
                            try
                            {
                                $typeString = $member.Definition.Split(" ")[0]
                                $memberType = [type]$typeString
                                $typeKnown = $true
                            }
                            catch
                            {
                                $memberType = $null
                                $typeKnown = $false
                            }
                            
                            $properties[$member.Name] = [pscustomobject]@{
                                Name = $member.Name
                                Type = $memberType
                                TypeKnown = $typeKnown
                            }
                        }
                        return $properties
                    }
                    'ArrayLiteralAst'
                    {
                        # Not yet supported
                        return @{ }
                    }
                }
                #region Input from Variable
                if ($pipelineAst.PipelineElements[$inputIndex].Expression -and $pipelineAst.PipelineElements[0].Expression[0].VariablePath)
                {
                    $properties += ((Get-Variable -Name $pipelineAst.PipelineElements[0].Expression[0].VariablePath.UserPath -ValueOnly) | Select-Object -First 1 | Get-Member -MemberType Properties).Name
                }
                #endregion Input from Variable
            }
            #endregion Variables or static input
            
            #region Input from Command
            'System.Management.Automation.Language.CommandAst'
            {
                $command = Get-Command $InputObject.CommandElements[0].Value -ErrorAction Ignore
                if ($command -is [System.Management.Automation.AliasInfo]) { $command = $command.ResolvedCommand }
                if (-not $command) { return $properties }
                
                foreach ($type in $command.OutputType.Type)
                {
                    foreach ($member in $type.GetMembers("Instance, Public"))
                    {
                        # Skip all members except Fields (4) or Properties (16)
                        if (-not ($member.MemberType -band 20)) { continue }
                        
                        $properties[$member.Name] = [pscustomobject]@{
                            Name = $member.Name
                            Type = $null
                            TypeKnown = $true
                        }
                        if ($member.PropertyType) { $properties[$member.Name].Type = $member.PropertyType }
                        else { $properties[$member.Name].Type = $member.FieldType }
                    }
                    
                    foreach ($propertyExtensionItem in ([PSFramework.TabExpansion.TabExpansionHost]::InputCompletionTypeData[$type.FullName]))
                    {
                        $properties[$propertyExtensionItem.Name] = $propertyExtensionItem
                    }
                }
                
                #region Command Specific Inserts
                foreach ($propertyExtensionItem in ([PSFramework.TabExpansion.TabExpansionHost]::InputCompletionCommandData[$command.Name]))
                {
                    $properties[$propertyExtensionItem.Name] = $propertyExtensionItem
                }
                #endregion Command Specific Inserts
                
                return $properties
            }
            #endregion Input from Command
            
            # Unknown / Unexpected input
            default { return @{ } }
        }
    }
    
    function Update-Property
    {
        [CmdletBinding()]
        param (
            [Hashtable]
            $Property,
            
            $Step
        )
        
        $properties = @{ }
        #region Expand Property
        if ($Step.ExpandProperty)
        {
            if (-not ($Property[$Step.ExpandProperty])) { return $properties }
            
            $expanded = $Property[$Step.ExpandProperty]
            if (-not $expanded.TypeKnown) { return $properties }
            
            foreach ($member in $expanded.Type.GetMembers("Instance, Public"))
            {
                # Skip all members except Fields (4) or Properties (16)
                if (-not ($member.MemberType -band 20)) { continue }
                
                $properties[$member.Name] = [pscustomobject]@{
                    Name = $member.Name
                    Type = $null
                    TypeKnown = $true
                }
                if ($member.PropertyType) { $properties[$member.Name].Type = $member.PropertyType }
                else { $properties[$member.Name].Type = $member.FieldType }
            }
            
            foreach ($propertyExtensionItem in ([PSFramework.TabExpansion.TabExpansionHost]::InputCompletionTypeData[$expanded.Type.FullName]))
            {
                $properties[$propertyExtensionItem.Name] = $propertyExtensionItem
            }
            
            return $properties
        }
        #endregion Expand Property
        
        # In keep input mode, the original properties will not be affected in any way
        if ($Step.KeepInputObject) { $properties = $Property.Clone() }
        $filterProperties = $Step.Properties | Where-Object Kind -eq "Property"
        
        #region Select What to keep
        if (-not $Step.KeepInputObject)
        {
            :main foreach ($propertyItem in $Property.Values)
            {
                #region Excluded Properties
                foreach ($exclusion in $Step.Excluded)
                {
                    if ($propertyItem.Name -like $exclusion) { continue main }
                }
                #endregion Excluded Properties
                
                foreach ($stepProperty in $filterProperties)
                {
                    if ($propertyItem.Name -like $stepProperty.Name)
                    {
                        $properties[$propertyItem.Name] = $propertyItem
                        continue main
                    }
                }
            }
        }
        #endregion Select What to keep
        
        #region Adding Content
        :main foreach ($stepProperty in $Step.Properties)
        {
            switch ($stepProperty.Kind)
            {
                'Property'
                {
                    if ($stepProperty.Filter) { continue main }
                    if ($properties[$stepProperty.Name]) { continue main }
                    
                    foreach ($exclusion in $Step.Excluded)
                    {
                        if ($stepProperty.Name -like $exclusion) { continue main }
                    }
                    
                    $properties[$stepProperty.Name] = [PSCustomObject]@{
                        Name = $stepProperty.Name
                        Type = $null
                        TypeKnown = $false
                    }
                    continue main
                }
                'CalculatedProperty'
                {
                    if ($properties[$stepProperty.Name]) { continue main }
                    
                    $properties[$stepProperty.Name] = [PSCustomObject]@{
                        Name = $stepProperty.Name
                        Type = $null
                        TypeKnown = $false
                    }
                    continue main
                }
                'ScriptProperty'
                {
                    if ($properties[$stepProperty.Name]) { continue main }
                    
                    $properties[$stepProperty.Name] = [PSCustomObject]@{
                        Name = $stepProperty.Name
                        Type = $null
                        TypeKnown = $false
                    }
                    continue main
                }
                'AliasProperty'
                {
                    if ($properties[$stepProperty.Name]) { continue main }
                    
                    $properties[$stepProperty.Name] = [PSCustomObject]@{
                        Name = $stepProperty.Name
                        Type = $null
                        TypeKnown = $false
                    }
                    if ($properties[$stepProperty.Target].TypeKnown)
                    {
                        $properties[$stepProperty.Name].Type = $properties[$stepProperty.Target].Type
                        $properties[$stepProperty.Name].TypeKnown = $properties[$stepProperty.Target].TypeKnown
                    }
                    
                    continue main
                }
            }
        }
        #endregion Adding Content
        $properties
    }
    
    function Read-SelectObject
    {
        [CmdletBinding()]
        param (
            [System.Management.Automation.Language.CommandAst]
            $Ast,
            
            [string]
            $CommandName = 'Select-Object'
        )
        
        $results = [pscustomobject]@{
            Ast                = $Ast
            BoundParameters = @()
            Property        = @()
            ExcludeProperty = @()
            ExpandProperty  = ''
            ScriptProperty  = @()
            AliasProperty   = @()
            KeepInputObject = $false
        }
        
        #region Process Ast
        if ($Ast.CommandElements.Count -gt 1)
        {
            $index = 1
            $parameterName = ''
            $position = 0
            while ($index -lt $Ast.CommandElements.Count)
            {
                $element = $Ast.CommandElements[$index]
                switch ($element.GetType().FullName)
                {
                    'System.Management.Automation.Language.CommandParameterAst'
                    {
                        $parameterName = $element.ParameterName
                        if ($parameterName -like "k*") { $results.KeepInputObject = $true }
                        $results.BoundParameters += $element.ParameterName
                        break
                    }
                    'System.Management.Automation.Language.StringConstantExpressionAst'
                    {
                        if (-not $parameterName)
                        {
                            switch ($position)
                            {
                                0 { $results.Property = $element }
                                1 { $results.AliasProperty = $element }
                                2 { $results.ScriptProperty = $element }
                            }
                            $position = $position + 1
                        }
                        
                        if ($parameterName -like "pr*") { $results.Property = $element }
                        if ($parameterName -like "exp*") { $results.ExpandProperty = $element.Value }
                        if ($parameterName -like "exc*") { $results.ExcludeProperty = $element.Value }
                        if ($parameterName -like "a*") { $results.AliasProperty = $element }
                        if ($parameterName -like "scriptp*") { $results.ScriptProperty = $element }
                        $parameterName = ''
                        break
                    }
                    'System.Management.Automation.Language.ArrayLiteralAst'
                    {
                        if (-not $parameterName)
                        {
                            switch ($position)
                            {
                                0 { $results.Property = $element.Elements }
                                1 { $results.AliasProperty = $element.Elements }
                                2 { $results.ScriptProperty = $element.Elements }
                            }
                            $position = $position + 1
                        }
                        
                        if ($parameterName -like "pr*") { $results.Property = $element.Elements }
                        if ($parameterName -like "exp*") { $results.ExpandProperty = $element.Elements.Value }
                        if ($parameterName -like "exc*") { $results.ExcludeProperty = $element.Elements.Value }
                        if ($parameterName -like "a*") { $results.AliasProperty = $element.Elements }
                        if ($parameterName -like "scriptp*") { $results.ScriptProperty = $element.Elements }
                        
                        $parameterName = ''
                        break
                    }
                    'System.Management.Automation.Language.ConstantExpressionAst'
                    {
                        if (-not $parameterName)
                        {
                            switch ($position)
                            {
                                0 { $results.Property = $element }
                                1 { $results.AliasProperty = $element }
                                2 { $results.ScriptProperty = $element }
                            }
                            $position = $position + 1
                        }
                        
                        if ($parameterName -like "pr*") { $results.Property = $element }
                        if ($parameterName -like "exp*") { $results.ExpandProperty = $element.Value.ToString() }
                        if ($parameterName -like "exc*") { $results.ExcludeProperty = $element.Value.ToString() }
                        if ($parameterName -like "a*") { $results.AliasProperty = $element }
                        if ($parameterName -like "scriptp*") { $results.ScriptProperty = $element }
                        $parameterName = ''
                        break
                    }
                    'System.Management.Automation.Language.HashtableAst'
                    {
                        if (-not $parameterName)
                        {
                            switch ($position)
                            {
                                0 { $results.Property = $element }
                                1 { $results.AliasProperty = $element }
                                2 { $results.ScriptProperty = $element }
                            }
                            $position = $position + 1
                        }
                        
                        if ($parameterName -like "pr*") { $results.Property = $element }
                        if ($parameterName -like "a*") { $results.AliasProperty = $element }
                        if ($parameterName -like "scriptp*") { $results.ScriptProperty = $element }
                        $parameterName = ''
                        break
                    }
                    default
                    {
                        $parameterName = ''
                    }
                }
                $index = $index + 1
            }
        }
        #endregion Process Ast
        
        #region Convert Results
        $resultsProcessed = [pscustomobject]@{
            HasIncludeFilter = $false
            RawResult         = $results
            Properties         = @()
            Excluded         = $results.ExcludeProperty
            ExpandProperty   = $results.ExpandProperty
            KeepInputObject  = $results.KeepInputObject
        }
        
        switch ($CommandName)
        {
            #region Select-Object
            'Select-Object'
            {
                #region Properties
                foreach ($element in $results.Property)
                {
                    switch ($element.GetType().FullName)
                    {
                        'System.Management.Automation.Language.HashtableAst'
                        {
                            try
                            {
                                $resultsProcessed.Properties += [pscustomobject]@{
                                    Name = ($element.KeyValuePairs | Where-Object Item1 -Match '^N$|^Name$|^L$|^Label$' | Select-Object -First 1).Item2.PipelineElements[0].Expression.Value
                                    Kind = "CalculatedProperty"
                                    Type = "Unknown"
                                    Filter = $false
                                }
                            }
                            catch { }
                        }
                        default
                        {
                            if ($element.Value -match "\*") { $resultsProcessed.HasIncludeFilter = $true }
                            
                            $resultsProcessed.Properties += [pscustomobject]@{
                                Name = $element.Value.ToString()
                                Kind = "Property"
                                Type = "Inherited"
                                Filter = $element.Value -match "\*"
                            }
                        }
                    }
                }
                #endregion Properties
            }
            #endregion Select-Object
            
            #region Select-PSFObject
            'Select-PSFObject'
            {
                #region Properties
                foreach ($element in $results.Property)
                {
                    switch ($element.GetType().FullName)
                    {
                        'System.Management.Automation.Language.HashtableAst'
                        {
                            try
                            {
                                $resultsProcessed.Properties += [pscustomobject]@{
                                    Name = ($element.KeyValuePairs | Where-Object Item1 -Match '^N$|^Name$|^L$|^Label$' | Select-Object -First 1).Item2.PipelineElements[0].Expression.Value
                                    Kind = "CalculatedProperty"
                                    Type = "Unknown"
                                    Filter = $false
                                }
                            }
                            catch { }
                        }
                        default
                        {
                            try { $parameterItem = ([PSFramework.Parameter.SelectParameter]$element.Value).Value }
                            catch { continue }
                            
                            if ($parameterItem -is [System.String])
                            {
                                if ($parameterItem -match "\*") { $resultsProcessed.HasIncludeFilter = $true }
                                
                                $resultsProcessed.Properties += [pscustomobject]@{
                                    Name   = $parameterItem
                                    Kind   = "Property"
                                    Type   = "Inherited"
                                    Filter = $parameterItem -match "\*"
                                }
                            }
                            else
                            {
                                $resultsProcessed.Properties += [pscustomobject]@{
                                    Name   = $parameterItem
                                    Kind   = "CalculatedProperty"
                                    Type   = "Unknown"
                                    Filter = $false
                                }
                            }
                        }
                    }
                }
                #endregion Properties
                
                #region Script Properties
                foreach ($scriptProperty in $results.ScriptProperty)
                {
                    switch ($scriptProperty.GetType().FullName)
                    {
                        'System.Management.Automation.Language.HashtableAst'
                        {
                            foreach ($name in $scriptProperty.KeyValuePairs.Item1.Value)
                            {
                                $resultsProcessed.Properties += [pscustomobject]@{
                                    Name   = $name
                                    Kind   = "ScriptProperty"
                                    Type   = "Unknown"
                                    Filter = $false
                                }
                            }
                        }
                        default
                        {
                            try { $propertyValue = [PSFramework.Parameter.SelectScriptPropertyParameter]$scriptProperty.Value }
                            catch { continue }
                            
                            $resultsProcessed.Properties += [pscustomobject]@{
                                Name = $propertyValue.Value.Name
                                Kind = "ScriptProperty"
                                Type = "Unknown"
                                Filter = $false
                            }
                        }
                    }
                }
                #endregion Script Properties
                
                #region Alias Properties
                foreach ($scriptProperty in $results.AliasProperty)
                {
                    switch ($scriptProperty.GetType().FullName)
                    {
                        'System.Management.Automation.Language.HashtableAst'
                        {
                            foreach ($aliasPair in $scriptProperty.KeyValuePairs)
                            {
                                $resultsProcessed.Properties += [pscustomobject]@{
                                    Name = $aliasPair.Item1.Value
                                    Kind = "AliasProperty"
                                    Type = "Alias"
                                    Filter = $false
                                    Target = $aliasPair.Item2.PipelineElements.Expression.Value
                                }
                            }
                        }
                        default
                        {
                            try { $propertyValue = [PSFramework.Parameter.SelectAliasParameter]$scriptProperty.Value }
                            catch { continue }
                            
                            $resultsProcessed.Properties += [pscustomobject]@{
                                Name = $propertyValue.Aliases[0].Name
                                Kind = "AliasProperty"
                                Type = "Alias"
                                Filter = $false
                                Target = $propertyValue.Aliases[0].ReferencedMemberName
                            }
                        }
                    }
                }
                #endregion Alias Properties
            }
            #endregion Select-PSFObject
        }
        #endregion Convert Results
        
        $resultsProcessed
    }
    #endregion Utility Functions
    
    # Grab Pipeline and find starting index
    [System.Management.Automation.Language.PipelineAst]$pipelineAst = $commandAst.parent
    $index = $pipelineAst.PipelineElements.IndexOf($commandAst)
    
    # If it's the first item: Skip, no input to parse
    if ($index -lt 1) { return }
    
    $inputIndex = $index - 1
    $steps = @{ }
    
    #region Step backwards through the pipeline until the definitive object giver is found
    :outmain while ($true)
    {
        if ($pipelineAst.PipelineElements[$inputIndex].CommandElements)
        {
            # Resolve command and fail if it breaks
            $command = $null
            # Work around the ? alias for Where-Object being a wildcard
            if ($pipelineAst.PipelineElements[$inputIndex].CommandElements[0].Value -eq "?") { $command = Get-Alias -Name "?" | Where-Object Name -eq "?" }
            else { $command = Get-Command $pipelineAst.PipelineElements[$inputIndex].CommandElements[0].Value -ErrorAction Ignore }
            if ($command -is [System.Management.Automation.AliasInfo]) { $command = $command.ResolvedCommand }
            if (-not $command) { return }
            
            switch ($command.Name)
            {
                'Where-Object'
                {
                    $steps[$inputIndex] = [pscustomobject]@{
                        Index = $inputIndex
                        Skip  = $true
                        Type  = 'Where'
                    }
                    $inputIndex = $inputIndex - 1
                    continue outmain
                }
                'Tee-Object'
                {
                    $steps[$inputIndex] = [pscustomobject]@{
                        Index = $inputIndex
                        Skip  = $true
                        Type  = 'Tee'
                    }
                    $inputIndex = $inputIndex - 1
                    continue outmain
                }
                'Sort-Object'
                {
                    $steps[$inputIndex] = [pscustomobject]@{
                        Index = $inputIndex
                        Skip  = $true
                        Type  = 'Sort'
                    }
                    $inputIndex = $inputIndex - 1
                    continue outmain
                }
                #region Select-Object
                'Select-Object'
                {
                    $selectObject = Read-SelectObject -Ast $pipelineAst.PipelineElements[$inputIndex] -CommandName 'Select-Object'
                    
                    $steps[$inputIndex] = [pscustomobject]@{
                        Index = $inputIndex
                        Skip  = $false
                        Type  = 'Select'
                        Data  = $selectObject
                    }
                    
                    if ($selectObject.HasIncludeFilter -or ($selectObject.Properties.Type -eq "Inherited") -or $selectObject.ExpandProperty)
                    {
                        $inputIndex = $inputIndex - 1
                        continue outmain
                    }
                    break outmain
                }
                #endregion Select-Object
                #region Select-PSFObject
                'Select-PSFObject'
                {
                    $selectObject = Read-SelectObject -Ast $pipelineAst.PipelineElements[$inputIndex] -CommandName 'Select-PSFObject'
                    
                    $steps[$inputIndex] = [pscustomobject]@{
                        Index = $inputIndex
                        Skip  = $false
                        Type  = 'PSFSelect'
                        Data  = $selectObject
                    }
                    
                    if ($selectObject.HasIncludeFilter -or ($selectObject.Properties.Type -eq "Inherited") -or $selectObject.ExpandProperty)
                    {
                        $inputIndex = $inputIndex - 1
                        continue outmain
                    }
                    break outmain
                }
                #endregion Select-PSFObject
                default { break outmain }
            }
        }
        
        else
        {
            break
        }
    }
    #endregion Step backwards through the pipeline until the definitive object giver is found
    
    # Catch moving through _all_ options in the pipeline
    if ($inputIndex -lt 0) { return }
    
    #region Process resulting / reaching properties
    $properties = Get-Property -InputObject $pipelineAst.PipelineElements[$inputIndex]
    $inputIndex = $inputIndex + 1
    
    while ($inputIndex -lt $index)
    {
        # Eliminate preliminary follies
        if (-not $steps[$inputIndex]) { $inputIndex = $inputIndex + 1; continue }
        if ($steps[$inputIndex].Skip) { $inputIndex = $inputIndex + 1; continue }
        
        # Process the current step, then move on unless done
        $properties = Update-Property -Property $properties -Step $steps[$inputIndex].Data
        
        $inputIndex = $inputIndex + 1
    }
    #endregion Process resulting / reaching properties
    
    $properties.Keys | Sort-Object
} -Global