File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1207,17 +1207,9 @@ private static void GetStandardPlatformPaths(
12071207 out string localUserDir ,
12081208 out string allUsersDir )
12091209 {
1210- // Get PowerShell engine version from $PSVersionTable.PSVersion
1211- Version psVersion = new Version ( 5 , 1 ) ;
1212- try
1213- {
1214- dynamic psVersionObj = ( psCmdlet . SessionState . PSVariable . GetValue ( "PSVersionTable" ) as Hashtable ) ? [ "PSVersion" ] ;
1215- if ( psVersionObj != null ) psVersion = new Version ( ( int ) psVersionObj . Major , ( int ) psVersionObj . Minor ) ;
1216- }
1217- catch {
1218- // Fallback if dynamic access fails
1219- psCmdlet . WriteWarning ( "Unable to determine PowerShell version from $PSVersionTable" ) ;
1220- }
1210+ // Get PowerShell engine version from $PSVersionTable.PSVersion (automatic variable, always available)
1211+ dynamic psVersionObj = ( psCmdlet . SessionState . PSVariable . GetValue ( "PSVersionTable" ) as Hashtable ) [ "PSVersion" ] ;
1212+ Version psVersion = new Version ( ( int ) psVersionObj . Major , ( int ) psVersionObj . Minor ) ;
12211213
12221214 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
12231215 {
You can’t perform that action at this time.
0 commit comments