Private/Get-PSMajorVersion.ps1
|
function Get-PSMajorVersion { <# .SYNOPSIS Returns the major version number of the current PowerShell host. .DESCRIPTION Thin wrapper around $PSVersionTable.PSVersion.Major that enables Pester tests to mock the PS version without modifying the read-only $PSVersionTable automatic variable. Invoke-EnvkStartup calls this function to determine whether to use the parallel (PS 7+) or sequential (PS 5.1) launch path. .OUTPUTS [int] -- The major version of the running PowerShell host (e.g., 5 or 7). .NOTES Author: Aaron AlAnsari Created: 2026-02-26 This function is a testability boundary helper only. All callers should use it instead of reading $PSVersionTable.PSVersion.Major directly so that Pester's InModuleScope Mock can intercept it during unit tests. #> [CmdletBinding()] [OutputType([int])] param () return $PSVersionTable.PSVersion.Major } |