Skip to content

Conversation

@littleKitchen
Copy link
Contributor

Summary

Add standardized requirements header block to all 13 production PowerShell scripts for consistent error handling, PowerShell version requirements, and strict mode enforcement.

Changes

  • Added #Requires -Version 7.0 before param() block
  • Added Set-StrictMode -Version Latest after param() block
  • Added $ErrorActionPreference = 'Stop' after Set-StrictMode
  • Removed duplicate $ErrorActionPreference assignments from script bodies

Files Modified (13 total)

  • scripts/linting/*.ps1 (6 files)
  • scripts/security/*.ps1 (3 files)
  • scripts/extension/*.ps1 (2 files)
  • scripts/lib/Get-VerifiedDownload.ps1
  • scripts/dev-tools/Generate-PrReference.ps1

Validation

  • ✅ PSScriptAnalyzer passes with no new issues
  • ✅ All 13 scripts have standardized header block
  • ✅ No duplicate $ErrorActionPreference assignments

Fixes #286

…soft#286)

Add standardized header block to all 13 production PowerShell scripts:
- #Requires -Version 7.0 (before param block)
- Set-StrictMode -Version Latest (after param block)
- $ErrorActionPreference = 'Stop' (after Set-StrictMode)

Files modified:
- scripts/linting/*.ps1 (6 files)
- scripts/security/*.ps1 (3 files)
- scripts/extension/*.ps1 (2 files)
- scripts/lib/Get-VerifiedDownload.ps1
- scripts/dev-tools/Generate-PrReference.ps1

Removed duplicate $ErrorActionPreference assignments from script bodies.

Fixes microsoft#286
@littleKitchen littleKitchen requested a review from a team as a code owner January 31, 2026 20:14
Copy link
Contributor

@katriendg katriendg left a comment

Choose a reason for hiding this comment

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

Thanks for your PR!
It is looking very good, though there is a bit of a difference between some versions.
For consistency, let's always position the #Requires block before <# .SYNOPSIS #> block (when there is one).

Example

# file header stuff here
#Requires -Version 7.0

<#
.SYNOPSIS
....

Already correct:

  1. scripts/linting/Markdown-Link-Check.ps1

The files to change:
INCONSISTENT - #Requires AFTER synopsis (9 files need correction):**

  1. scripts/linting/Invoke-YamlLint.ps1

    • <# .SYNOPSIS #> at line 4, #Requires at line 33
    • Should move #Requires to line 4 (before synopsis)
  2. scripts/extension/Package-Extension.ps1

    • <# .SYNOPSIS #> at line 5, #Requires at line 58
    • Should move #Requires to line 4 (before synopsis)
  3. scripts/extension/Prepare-Extension.ps1

    • <# .SYNOPSIS #> at line 5, #Requires at line 45
    • Should move #Requires to line 4 (before synopsis)
  4. scripts/lib/Get-VerifiedDownload.ps1

    • <# .SYNOPSIS #> at line 4, #Requires at line 39
    • Should move #Requires to line 4 (before synopsis)
  5. scripts/linting/Link-Lang-Check.ps1

    • <# .SYNOPSIS #> at line 4, #Requires at line 49
    • Should move #Requires to line 3 (before synopsis)
  6. scripts/security/Test-DependencyPinning.ps1

    • <# .SYNOPSIS #> at line 4, #Requires at line 85
    • Should move #Requires to line 4 (before synopsis)
  7. scripts/security/Test-SHAStaleness.ps1

    • <# .SYNOPSIS #> at line 4, #Requires at line 51
    • Should move #Requires to line 4 (before synopsis)
  8. scripts/security/Update-ActionSHAPinning.ps1

    • <# .SYNOPSIS #> at line 5, #Requires at line 34
    • Should move #Requires to line 4 (before synopsis)
  9. scripts/dev-tools/Generate-PrReference.ps1

    • <# .SYNOPSIS #> at line 4, #Requires at line 20
    • Should move #Requires to line 4 (before synopsis)

WilliamBerryiii and others added 2 commits February 2, 2026 09:38
Standardizes header order across all PowerShell scripts:
1. Shebang (if present)
2. Copyright header
3. #Requires statements
4. Synopsis block

Files updated:
- scripts/linting/Invoke-YamlLint.ps1
- scripts/extension/Package-Extension.ps1
- scripts/extension/Prepare-Extension.ps1
- scripts/lib/Get-VerifiedDownload.ps1
- scripts/linting/Link-Lang-Check.ps1
- scripts/security/Test-DependencyPinning.ps1
- scripts/security/Test-SHAStaleness.ps1
- scripts/security/Update-ActionSHAPinning.ps1
- scripts/dev-tools/Generate-PrReference.ps1
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.

Standardize PowerShell script requirements header block

3 participants