Repository navigation
feat(harness): script paths from the pipeline, and a view for every result type - #22
Conversation
fadwen
left a comment
There was a problem hiding this comment.
Notes on the lines whose reason the diff does not show.
| if ($signature.Status -ne 'Valid') { | ||
| $reasons.Add("Signature status ${signatureStatus}: with the signature check enforced the agent " + | ||
| 'does not run the script and reports not detected (exit 1 from AgentExecutor)') | ||
| process { |
There was a problem hiding this comment.
A function body outside begin/process/end runs once, as end, with -Path bound to the last piped object only. The process block is what makes a piped list run each script; the body inside it is unchanged apart from indentation and three wrapped lines.
| </ListControl> | ||
| </View> | ||
| <View> | ||
| <Name>IntuneScriptLab.RuleResult</Name> |
There was a problem hiding this comment.
List views, like the other per-run results, because each carries a Reason sentence that a table would truncate; the Rule line folds Kind, Operation, Operator and Value into the shape the portal shows the rule in.
| <ListItem><PropertyName>Reason</PropertyName></ListItem> | ||
| <ListItem><PropertyName>Applicability</PropertyName></ListItem> | ||
| <ListItem><PropertyName>Details</PropertyName></ListItem> | ||
| <ListItem><Label>Checks</Label><ScriptBlock>($_.Checks | ForEach-Object { "$($_.Requirement): $(if ($_.Met) { 'met' } else { 'not met' })" }) -join "; "</ScriptBlock></ListItem> |
There was a problem hiding this comment.
The Checks array is summarised to one line per requirement so the default output stays a screen; the full objects are still on the property for anyone who wants them.
| # A result type without a view prints as a property dump; the view is part of the command's contract | ||
| $declared = @(Get-Command -Module IntuneScriptLab -CommandType Function | ForEach-Object { | ||
| $_.OutputType.Name | ||
| } | Where-Object { $_ -like 'IntuneScriptLab.*' } | Sort-Object -Unique) |
There was a problem hiding this comment.
Filtered to the module's own type names: Export-IntuneFindingSarif declares System.IO.FileInfo and the Assert-* functions declare nothing of their own, and neither needs a view here.
738faa9 to
285c7ce
Compare
…esult type Invoke-IntuneDetectionTest, Invoke-IntunePlatformScriptTest and Invoke-IntuneRequirementTest took one -Path and nothing from the pipeline, while Test-IntuneScript and Repair-IntuneScript take a folder's scripts straight from Get-ChildItem. The three now bind -Path by value and from a FullName or PSPath property, and run their body once per script; the help's INPUTS says so. Test-IntuneWin32Rule, Test-IntuneWin32Requirement and Export-IntuneAgentDiagnostic results printed as property dumps, the only result types without a format view. Each has a list view now, and the module contract test requires a view for every output type an exported command declares, so the next command cannot ship without one.
Summary
Invoke-IntuneDetectionTest,Invoke-IntunePlatformScriptTestandInvoke-IntuneRequirementTesttook one-Pathand nothing from the pipeline, whileTest-IntuneScriptandRepair-IntuneScripttake a folder's scripts straight fromGet-ChildItem. The three now bind-Pathby value and from aFullNameorPSPathproperty and run once per script. Separately,Test-IntuneWin32Rule,Test-IntuneWin32RequirementandExport-IntuneAgentDiagnosticresults printed as property dumps, the only result types without a format view; each has one now, and the module contract requires a view for every output type an exported command declares.Stacked on #21 (base branch); the diff is this change only. Merge #16 through #21, then this.
Changes
Public/Invoke-IntuneDetectionTest.ps1,Invoke-IntunePlatformScriptTest.ps1,Invoke-IntuneRequirementTest.ps1.-PathgainsValueFromPipeline,ValueFromPipelineByPropertyNameand theFullNameandPSPathaliases, the same shape asTest-IntuneScript; the body moves into aprocessblock, otherwise only the last piped script would run. No other change to the bodies beyond re-indentation and three lines wrapped to the line limit.IntuneScriptLab.Format.ps1xml. List views forIntuneScriptLab.RuleResult(the rule as one line, target, actual value, reason),IntuneScriptLab.ApplicabilityResult(verdict, reason, the checks as met or not met) andIntuneScriptLab.Diagnostic(path, size in MB, counts).Tests/Unit/Module.Contract.Tests.ps1. EveryIntuneScriptLab.*output type an exported command declares has a view.Get-ChildItem, two strings, the rule given once for the requirement test.Not in this change:
Invoke-IntuneRemediationTesttakes two paths andInvoke-IntuneWin32AppTesta content folder with rules, neither a shape a file listing maps onto; the tenant commands take-Idas a list already.Verification