Skip to content

Align remaining PowerShell scripts with MSX script standard #481

Open

Description

Problem

A repository-wide script check still finds multiple .ps1 files that do not follow the MSX PowerShell script baseline (#Requires -Version, script-level [CmdletBinding()], param(), and $ErrorActionPreference = 'Stop').

Current status

A first pass has already aligned the workflow/deployment scripts under:

  • .github/scripts/docs/*.ps1
  • .github/actions/update-index/src/Invoke-UpdateIndex.ps1
  • helper module naming for the update-index action (update-index.Helpers.psm1)

Remaining files flagged

  • .github/scripts/docs/Shared.ps1 (helper script shape differs from entry-script baseline)
  • guidance/*.ps1 examples:
    • Add-Array.ps1
    • Add-HashTable.ps1
    • Add-String.ps1
    • Caller.ps1
    • ClassExtension.ps1
    • Loops.ps1
    • Out-Null.ps1
    • PipelineExecution.ps1
    • PSCallStack.ps1
    • PSCmdlet.ps1
    • Read-File.ps1
    • root.ps1
    • WebCalls.ps1

Proposed resolution

  1. Decide policy for guidance/*.ps1 (strict runnable-script baseline vs snippet-style examples).
  2. If strict baseline applies, align each file to the standard structure and help format.
  3. If snippet style is intentional, document the exception clearly in repo guidance and exclude from baseline checks.
  4. Normalize Shared.ps1 by either:
    • converting it to a helper module (*.psm1) with explicit import usage, or
    • documenting why helper script format is intentionally exempt.

Activity

  1. MariusStorhaug commented on Nov 4, 2026

    @MariusStorhaug
    MemberAuthor

    The native-help review for #558 reads all 14 guidance files and preserves them under the complete-blob contract in docs/content/reference/guidance-scripts.md. The policy decision in this issue still applies before a writing-only pass changes those snapshots. Two concrete semantic findings also need separate verification: guidance/Read-File.ps1 line 15 uses $InputText.Length > 0; the PowerShell parser identifies > 0 as FileRedirectionAst, while its help promises a Boolean result. guidance/PSModuleTest.psm1 says to dot-source each file but calls Import-Module. #570 changes neither behavior nor guidance content and does not claim that these examples are corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions