File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -468,10 +468,10 @@ function Get-RunTimeEnvironment {
468468 $computerName = $env: ComputerName
469469 $userName = $env: Username
470470 if ($null -ne $SafeCommands [' Get-CimInstance' ]) {
471- $osSystemInformation = (& $SafeCommands [' Get-CimInstance' ] Win32_OperatingSystem)
471+ $osSystemInformation = (& $SafeCommands [' Get-CimInstance' ] Win32_OperatingSystem - ErrorAction Ignore )
472472 }
473473 elseif ($null -ne $SafeCommands [' Get-WmiObject' ]) {
474- $osSystemInformation = (& $SafeCommands [' Get-WmiObject' ] Win32_OperatingSystem)
474+ $osSystemInformation = (& $SafeCommands [' Get-WmiObject' ] Win32_OperatingSystem - ErrorAction Ignore )
475475 }
476476 elseif ($IsMacOS -or $IsLinux ) {
477477 $osSystemInformation = @ {
@@ -492,7 +492,9 @@ function Get-RunTimeEnvironment {
492492 # well, we tried
493493 }
494494 }
495- else {
495+
496+ # Fall back to unknown values if WMI/CIM returned null (e.g. access denied when not running as Administrator)
497+ if ($null -eq $osSystemInformation ) {
496498 $osSystemInformation = @ {
497499 Name = ' Unknown'
498500 Version = ' 0.0.0.0'
You can’t perform that action at this time.
0 commit comments