Skip to content

feat(harness): script paths from the pipeline, and a view for every result type - #22

Merged
fadwen merged 2 commits into
test/inbox-modules-against-hostfrom
feat/pipeline-input-and-views
Oct 6, 2026
Merged

fadwen merged 2 commits into
test/inbox-modules-against-hostfrom
feat/pipeline-input-and-views

Conversation

@fadwen

@fadwen fadwen commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Summary

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 once per script. Separately, Test-IntuneWin32Rule, Test-IntuneWin32Requirement and Export-IntuneAgentDiagnostic results 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. -Path gains ValueFromPipeline, ValueFromPipelineByPropertyName and the FullName and PSPath aliases, the same shape as Test-IntuneScript; the body moves into a process block, 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 for IntuneScriptLab.RuleResult (the rule as one line, target, actual value, reason), IntuneScriptLab.ApplicabilityResult (verdict, reason, the checks as met or not met) and IntuneScriptLab.Diagnostic (path, size in MB, counts).
  • Tests/Unit/Module.Contract.Tests.ps1. Every IntuneScriptLab.* output type an exported command declares has a view.
  • Tests. Each of the three commands run from the pipeline: two paths from Get-ChildItem, two strings, the rule given once for the requirement test.
  • Help. INPUTS says what the three take; the parameter tables carry the pipeline flags and aliases from the signature update. MAML rebuilt.

Not in this change: Invoke-IntuneRemediationTest takes two paths and Invoke-IntuneWin32AppTest a content folder with rules, neither a shape a file listing maps onto; the tenant commands take -Id as a list already.

Verification

  • Unit and integration suites pass on PowerShell 7.6.6; the three commands' tests and the module contract pass on Windows PowerShell 5.1. PSScriptAnalyzer (Error and Warning) is clean; no line over 115 characters; help Markdown validates and the MAML matches.

@fadwen fadwen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

fadwen added 2 commits October 6, 2026 02:00
…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.
@fadwen
fadwen added this pull request to stack #24 October 6, 2026 16:17
@fadwen
fadwen merged commit 836f806 into main Oct 6, 2026
4 checks passed
@fadwen
fadwen deleted the feat/pipeline-input-and-views branch October 6, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant