Repository navigation
Open
Labels
enhancementNew feature or request
Description
Summary
ai-powershell-standards 2.0.0 was installed into this repository by pull requests #57 to #60. It replaced the earlier guidance with rules that carry IDs such as ERR-11 and STY-02, and several of them ask for things the module was not written to. This issue tracks the work of bringing the module into line. Each item below is one issue with its findings, a proposed change, and where needed a decision for the owner.
How the findings were produced
- The standards' own check,
Tools/Test-StandardsCompliance.ps1at commit 79872d2 of ai-powershell-standards, run over this repository at commit d009d39 with PSScriptAnalyzer 1.25.0. It reports 2,919 findings: 2,512 of layout (STY-01, STY-02, STY-04, STY-07), 174 functions without help (DOC-01), 158 without[CmdletBinding()](FUN-01), 56throwstatements in advanced functions (ERR-11), and a handful of others. - A parse of every
.ps1and.psm1file for rules that check does not cover: help completeness, parameter types, pipeline parameters,-LiteralPath, encodings, version comparisons, and the test conventions. - A reading of the root module, the manifest, the build scripts, the workflows, the README and the help Markdown against the module, CI, README and PlatyPS rules.
- The full Pester suite at commit d009d39 as a baseline, on one Windows 11 26H2 computer. PowerShell 7.6.10: 1,043 tests, 1,032 passed, 8 skipped, 3 failed, 95.11 percent coverage. Windows PowerShell 5.1: 996 passed, 44 skipped, the same 3 failed. The three failures are Repair-IntuneScript corrupts an ANSI script on a host with a UTF-8 system code page #75 and In-box module table does not list UOPProviders, present on Windows 11 26H2 #76 and do not occur in CI.
To repeat the first step from a checkout of ai-powershell-standards:
./Tools/Test-StandardsCompliance.ps1 -Path <path to IntuneScriptLab> -PassThru | Group-Object -Property RuleIdIssues
Requirements the module does not meet, in the order the changes stack most easily:
- Build and release scripts depart from the 2.0 standards (VER-05, MOD-12, SEC-50, ERR-01) #61 Build and release scripts (VER-05, MOD-12, SEC-50, ERR-01)
- CI gates: failed blocks pass, runs are unshuffled, tools are unpinned, no release rehearsal (TST-42, TST-46, CIC-02, CIC-10, CIC-11) #62 CI gates (TST-42, TST-46, CIC-02, CIC-10, CIC-11)
- Root module does not set strict mode or fail the import on a load error (ERR-02, ERR-03, MOD-05) #63 Root module: strict mode and load failures (ERR-02, ERR-03, MOD-05)
- Advanced functions end with throw instead of ThrowTerminatingError (ERR-10, ERR-11, ERR-14) #64
throwin advanced functions (ERR-10, ERR-11, ERR-14) - Nested helper functions have no CmdletBinding, help or parameter types (FUN-01, DOC-01, FUN-20, MOD-01) #65 Nested helper functions (FUN-01, DOC-01, FUN-20, MOD-01)
- Private function help lacks mandatory keywords and output types (DOC-01, DOC-10, FUN-10) #66 Private function help and output types (DOC-01, DOC-10, FUN-10)
- Public commands: untyped parameters, non-array pipeline parameters, long synopses (FUN-20, FUN-21, DOC-10) #67 Public command parameters and synopses (FUN-20, FUN-21, DOC-10)
- Help Markdown: examples are not fenced and parameter drift is not gated (PLT-05, PLT-09) #68 Help Markdown (PLT-05, PLT-09)
- Small style and version departures in the shipped module (STY-32, STY-06, STY-21, STY-30, VER-07) #69 Small style and version items (STY-32, STY-06, STY-21, STY-30, VER-07)
- Tests reload the module in every file and run longer than the limits (TST-05, TST-47) #70 Tests (TST-05, TST-47)
- Validation kit scripts lack strict mode, help and terminating errors (ERR-01, ERR-11, DOC-01, FUN-01) #71 Validation kit (ERR-01, ERR-11, DOC-01, FUN-01)
- README lacks a table of contents and a quick start (RDM-08, RDM-16) #72 README (RDM-08, RDM-16)
- Source layout does not follow the standards and CI does not check it (STY-01, STY-02, STY-04, STY-07) #73 Layout, as the last change because it touches nearly every file (STY-01, STY-02, STY-04, STY-07)
Decisions for the owner:
- Standards rules that need a decision before any work (SEC-16, ERR-16, MOD-20, TST-43 and others) #74 Rules that ask for something the module does not have (SEC-16, ERR-16, MOD-20, TST-43 and others)
Defects found while the suites were run, which are not standards findings:
- Repair-IntuneScript corrupts an ANSI script on a host with a UTF-8 system code page #75
Repair-IntuneScriptcorrupts an ANSI script on a host with a UTF-8 system code page - In-box module table does not list UOPProviders, present on Windows 11 26H2 #76 The in-box module table does not list
UOPProviders
What already meets the rules
- Version targets: the manifest and the root module both declare 5.1, the suites pass under Windows PowerShell 5.1 in CI, and the standards' check finds no command that exists only in Windows PowerShell.
- Security basics: no
Invoke-Expression, no secrets in source, credentials taken as[PSCredential]with theCredential()attribute, no prompt for a missing value in a function. - Release: an allowlist staging folder, an import of the staged copy in a new process, a check for empty URI keys, and
-WhatIfthat rehearses everything but the upload (MOD-10, MOD-13, MOD-14). - Help: Microsoft.PowerShell.PlatyPS 1.0.3,
.EXTERNALHELPon every export, bare related links, anabout_topic, and a check on a case-sensitive file system. - Tests: the Pester 6.2.0
#Requiresline and tags on every file, one assertion style, a shuffled run with a coverage gate in CI, and a Windows PowerShell 5.1 job.
Discovered and written up with Claude Code.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
fadwen commentedon Nov 23, 2026
Progress on the first items, as a stack of four pull requests. Each is based on the one before it, so they merge in this order:
fix(release): the build and release scripts and the manifest. Closes Build and release scripts depart from the 2.0 standards (VER-05, MOD-12, SEC-50, ERR-01) #61.test(logs): the order-dependent test found while the suites were run for fix(release): bring the build scripts in line with the 2.0 standards #79. Closes A Get-IslAgentLogEvent test fails when the shuffle runs it first in its file #78.ci: one shuffled test runner for every job, pinned tools, a release rehearsal on pull requests, a nightly run and the security rules. Refs CI gates: failed blocks pass, runs are unshuffled, tools are unpinned, no release rehearsal (TST-42, TST-46, CIC-02, CIC-10, CIC-11) #62.ci:.gitattributesand what follows from an LF checkout. Closes CI gates: failed blocks pass, runs are unshuffled, tools are unpinned, no release rehearsal (TST-42, TST-46, CIC-02, CIC-10, CIC-11) #62.quality-gates.ymlstarts by itself only for pull requests intomain, which is #79. For the other three it was started by hand on the branch, and every job passed on each.Not started: #63 to #73. #63 (strict mode in the root module) and #64 (
throwin advanced functions) change what the module does at run time, and the harness paths that run elevated, as SYSTEM or as another account are skipped on the hosted runners, so those two need a run on a lab device before they are proposed.Discovered and written up with Claude Code.
fadwen commentedon Nov 23, 2026
The stack has two more pull requests. Each is based on the one before it, so the whole stack merges in this order: #79, #80, #81, #82, #84, #85.
fix(module): strict mode in the root module, a loader that fails the import when a file fails to load, and every read the suites then reported. Closes Root module does not set strict mode or fail the import on a load error (ERR-02, ERR-03, MOD-05) #63.test: four tests that were skipped on every run, found while fix(module): run under strict mode and fail the import on a load error #84 was run on a lab device. Closes Four tests never run: their -Skip condition reads a variable that BeforeAll sets after discovery #83.What was run for #84 beyond the hosted checks, because strict mode turns a silent
$nullinto an error at run time on paths the hosted runners skip:NT AUTHORITY\SYSTEMunder Windows PowerShell 5.1: 1,022 passed, 0 failed. The user-context suite ran there with the harness account.Not started: #64 to #73. #64 (
throwin advanced functions) is next, and needs the same run on a lab device.Discovered and written up with Claude Code.
fadwen commentedon Nov 23, 2026
The stack after the reviews of #79, #81, #82, #84 and #85. It merges in this order: #79, #80, #81, #82, #84, #87, #85.
Review findings, each fixed on the branch of its pull request and merged upward through the stack
Join-Pathcalls inPublish-Module.ps1.Tests/Invoke-Tests.ps1passed a run in which a filter left every test out; it now fails when no test passed or failed, and a test starts it that way. The CI step that repeated theScriptSecurityrules is removed, and the comment says what the workflow does and does not scan..gitattributescomment says what sets the three CRLF scripts apart, and the changelog says that a published package now ships LF scripts.Get-IslPropertyValuereads a generic dictionary.New since the last comment
TimedOutresult when the caller's error preference wasStop. It surfaced when test: decide the skip conditions of four tests during discovery #85 let the SYSTEM-context tests run in CI. fix(harness): end a timed-out run without taskkill's errors #87 fixes it and sits below test: decide the skip conditions of four tests during discovery #85 in the stack.State:
quality-gates.ymlpassed on every branch of the stack after these changes; for the six that are not based onmainit was started by hand. Not started: #64 to #73.Discovered and written up with Claude Code.
fadwen commentedon Nov 23, 2026
State after the merges of #79, #80, #81, #82 and #84 into
main, which closed #61, #62, #63 and #78.Open pull requests, in merge order
fix(harness): a timed-out run no longer fails on taskkill's messages under Windows PowerShell 5.1. test: decide the skip conditions of four tests during discovery #85 was merged into its branch, so it also carries the skip conditions that let the SYSTEM-context tests run. Closes A timed-out run throws on Windows PowerShell 5.1 when the caller's error preference is Stop #86 and Four tests never run: their -Skip condition reads a variable that BeforeAll sets after discovery #83. Approved; its checks pass.fix(logs)!: the first area of Advanced functions end with throw instead of ThrowTerminatingError (ERR-10, ERR-11, ERR-14) #64, the commands that read the agent's logs. Stacked on fix(harness): end a timed-out run without taskkill's errors #87.#64 is larger than its title. Replacing a
throwwithThrowTerminatingErrorlets the function that made the call carry on with nothing where the result should be, unless the call is inside atrywith acatch. 49 of the 54 calls in the module to a function that can fail were not. The measurements and the order of work are in a comment on #64. #89 adds a test that holds the rule for the whole module and lists the calls still to convert, 46 after this first area. Three areas remain: the runtime harness, the tenant commands, and the analysis and rule commands.New issue
Not started: #65 to #73.
Discovered and written up with Claude Code.
fadwen commentedon Nov 23, 2026
Two decisions were made and both are implemented.
ERR-13 for the log files (#89).
Get-IntuneAgentLogreports a path that does not exist, and a log it cannot read or parse, for that one item and goes on with the others.Get-IntuneAgentTimelineandExport-IntuneAgentDiagnosticread the logs through it, so they give what the readable logs hold.-WhatIfpreviews a run (#88, pull request #90). The fiveInvoke-Intune*Testcommands, the twoExport-commands andGet-IntuneScriptHealthaskShouldProcessbefore they run a script or write anything, and nothing inside the module consults the preference any more.Open pull requests, in merge order
fix(harness): closes A timed-out run throws on Windows PowerShell 5.1 when the caller's error preference is Stop #86 and Four tests never run: their -Skip condition reads a variable that BeforeAll sets after discovery #83. Approved.fix(logs)!: the first area of Advanced functions end with throw instead of ThrowTerminatingError (ERR-10, ERR-11, ERR-14) #64, with ERR-13.feat(harness): closes Under a WhatIf preference the harness skips its preparation and still starts the host #88.quality-gates.ymlpassed on all three; for #89 and #90 it was started by hand. #90 was also run on a lab device as SYSTEM under Windows PowerShell 5.1: every suite, 1,068 passed and none failed.Still open in #64: the runtime harness, the tenant commands, and the analysis and rule commands. 46 calls still rely on a
throwin the function they call; the list is inTests/Unit/Module.ErrorFlow.Tests.ps1.Not started: #65 to #73.
Discovered and written up with Claude Code.
fadwen commentedon Nov 24, 2026
State after the merges of #87, #89 and #90 into
main, which closed #83, #86 and #88.Open pull request
fix(harness)!: the runtime harness, the second area of Advanced functions end with throw instead of ThrowTerminatingError (ERR-10, ERR-11, ERR-14) #64, based onmain. It closes Runtime harness starts the host when the script could not be copied #91, which was found while reading the launch path: under PowerShell 7 a run whose script could not be copied started the host on a file that was not there.What #92 does
Invoke-Intune*Testcommands and the functions they launch through raise their failures withThrowTerminatingErrorand an ID each, and every call of such a function is inside atrywith acatch.Grant-IslFolderAccessno longer sets$ErrorActionPreference(ERR-02):icacls.exeandtaskkill.exerun through one private function that starts a process and reads its streams.Checked: every suite locally on PowerShell 7.6.10 and Windows PowerShell 5.1, on a lab device as SYSTEM under Windows PowerShell 5.1 (1,095 passed, none failed, with the SYSTEM-context tests and the tests that run as another account), the release rehearsal, and
quality-gates.ymlon the last commit, all five jobs.Still open in #64: the tenant commands, and the analysis and rule commands. 33 calls still rely on a
throwin the function they call, down from 46; the list is inTests/Unit/Module.ErrorFlow.Tests.ps1. The pull requests for those areas will be stacked on #92.Not started: #65 to #73.
Discovered and written up with Claude Code.