Repository navigation
Description
Summary
Seventy helper functions are defined inside other functions of the module. None has [CmdletBinding()] or help, most have untyped parameters, and none is in a file of its own. ai-powershell-standards 2.0.0 asks for every function to be an advanced function with help (FUN-01, DOC-01), with typed parameters and a declared output type (FUN-20, FUN-10), in its own file named after it (MOD-01).
Findings
Counts are from the standards' compliance check (FUN-01, DOC-01) and from a parse of each file (FUN-20, FUN-10).
| File | Nested helpers |
|---|---|
Public/Compare-IntuneDeployedScript.ps1 |
16 |
Public/Test-IntuneDeployedScript.ps1 |
10 |
Public/Get-IntuneScriptHealth.ps1 |
5 |
Public/Export-IntuneAgentDiagnostic.ps1 |
4 |
Public/Invoke-IntuneWin32AppTest.ps1 |
4 |
Public/Test-IntuneAssignmentFilter.ps1 |
4 |
Public/Export-IntuneFindingSarif.ps1 |
1 |
Public/Test-IntuneScript.ps1 |
1 |
Public/Test-IntuneWin32Requirement.ps1 |
1 |
Private/ConvertFrom-IslFilterRule.ps1 |
11 |
Private/Rules/Find-IslInteractiveCall.ps1 |
3 |
Private/Rules/Find-IslExitCodeIssue.ps1 |
2 |
Private/Rules/Find-IslModuleDependency.ps1 |
2 |
Private/Get-IslAgentLogEvent.ps1 |
2 |
Private/Invoke-IslGraphRequest.ps1 |
2 |
Private/Get-IslSetting.ps1 |
1 |
- FUN-01 and DOC-01: all 69 nested helpers, and the top-level
Test-IslPesterAssertionSupportinPublic/Assert-IntuneResult.ps1, have no[CmdletBinding()]and no help. - FUN-20: 47 parameters of nested helpers have no type, and 4 are
[bool]where the rule asks for[switch]. - FUN-10: none of the 69 declares
[OutputType()]. - MOD-01: two files hold several top-level functions.
Public/Assert-IntuneResult.ps1holds the seven exportedAssert-*functions and one helper, andPrivate/Find-IslAstNode.ps1holds seven functions.Private/Resolve-IslAccount.ps1holds two. - Three public commands each define their own
Test-WantedandGet-WantedPolicy. The copies differ, and the names say nothing about which command they belong to.
The nested helpers also read the variables of the function around them. FUN-06 covers the one case that has already gone wrong here, $PSBoundParameters inside a nested helper being the helper's own.
Proposed change
Move each helper to its own file under Private, as an advanced function with an Isl prefix, typed parameters, [OutputType()] and full comment-based help, and pass it what it reads from the outer function as parameters. Split Assert-IntuneResult.ps1 and Find-IslAstNode.ps1 into one file for each function. Where two commands share a helper that does the same work, keep one copy.
This is the largest change in the set and it changes no behaviour, so it can be done one public command at a time, each with the command's existing tests as the check, plus InModuleScope tests for helpers that carry logic of their own.
Decision needed
The standards have no rule that forbids a nested function as such. If the owner prefers to keep small closures nested, FUN-01, DOC-01, FUN-20 and FUN-10 still apply to them in place, and each helper kept nested needs [CmdletBinding()], a param() block with types, an output type and help where it stands. Moving them out is the smaller amount of text for each function and the only form that also meets MOD-01.
Discovered and written up with Claude Code.
Activity
fadwen commentedon Nov 24, 2026
Decision by the owner: move the helpers out. Each nested helper becomes its own file under
Private, an advanced function with anIslprefix, typed parameters,[OutputType()]and full comment-based help, and it takes what it read from the outer function as parameters. Copies that do the same work in several commands, such asTest-WantedandGet-WantedPolicy, become one.Assert-IntuneResult.ps1,Find-IslAstNode.ps1andResolve-IslAccount.ps1are split into one file for each function (MOD-01).The work goes one command, or one group of small helpers, at a time, each as its own pull request stacked on the one before, with the command's existing tests as the check and
InModuleScopetests for a helper that carries logic of its own. The first takes the four commands with one helper each (Test-IntuneScript,Test-IntuneWin32Requirement,Export-IntuneFindingSarif,Get-IslSetting).The last two
throwstatements of the module are in nested helpers (Get-IslSettingandInvoke-IslGraphRequest); once those helpers are advanced functions they end with$PSCmdlet.ThrowTerminatingError(), andTests/Unit/Module.ErrorFlow.Tests.ps1keeps the calls guarded.Discovered and written up with Claude Code.
fadwen commentedon Nov 24, 2026
Progress, as a stack of pull requests that merge in this order:
Test-IntuneScript,Test-IntuneWin32Requirement,Export-IntuneFindingSarif,Get-IslSetting(4 helpers). Based onmain; CI passed.Get-IslAgentLogEvent,Export-IntuneAgentDiagnostic,Invoke-IslGraphRequest(8 helpers). CI passed. With it, no function of the module usesthrow.Test-IntuneAssignmentFilter(4 helpers). CI passed.Find-IslInteractiveCall,Find-IslExitCodeIssue,Find-IslModuleDependency(7 helpers). The one helper that built a finding stays in its rule as a loop, becauseBuild/Build-RuleReference.ps1reads finding tables from the rule files only;docs/Rules.mdregenerates unchanged.23 of the 69 nested helpers are done. Each moved helper is a private function in its own file with full help, typed parameters and an output type, and has a test file of its own. Left:
ConvertFrom-IslFilterRule(11),Invoke-IntuneWin32AppTest(4),Get-IntuneScriptHealth(5),Test-IntuneDeployedScript(10),Compare-IntuneDeployedScript(16), and the split ofAssert-IntuneResult.ps1,Find-IslAstNode.ps1andResolve-IslAccount.ps1.Two things learned on the way, for the parts left: a
.DESCRIPTIONline that starts with.NETis read as a help keyword and leaves the function with no help thatGet-Helpfinds (the standards' check reports it as DOC-01), and a function that writes files declaresSupportsShouldProcessand is called with@script:IslInternal, whichTests/Unit/Module.WhatIf.Tests.ps1checks.Discovered and written up with Claude Code.