-1

I am running windows PRO

when I run the following command :

(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName

using a regular user in PowerShell the result is Windows 10 PRO though I am running Windows 11

when I run the same command using Admin mode I get :

Windows 10 Enterprise

Which is pretty amazing given the fact that it comes from the same registry key.

I was wondering if it is a bug and if someone have a better way getting the product name (like pro enterprise etc.)

running the same command in powershell (not through a .ps1 file) gives the same results.

5
  • 2
    Give Get-CimInstance Win32_OperatingSystem|% Caption a go Commented Nov 24, 2022 at 11:30
  • You can also decide what windows version is actually installed by looking at HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion item CurrentBuildNumber. Windows 10 have numbers there starting at 10000; Windows 11 starts with 20000 Commented Nov 24, 2022 at 12:47
  • 1
    ((Get-CimInstance Win32_OperatingSystem | select name).name).split('|')[0] - The name property would tell you the actual. Please run it and check. Commented Nov 24, 2022 at 21:22
  • thx Mathias that seems to be working great though I am still not sure why getting it from the registry in 2 different user modes ends with different result... Commented Nov 26, 2022 at 9:59
  • 4
    Does this answer your question? How to find the Windows version from the PowerShell command line Commented Nov 29, 2022 at 19:13

1 Answer 1

0

I have this bit of code. Releaseid seems deprecated. Ubr changes with each monthly update.

# patchcheck.ps1

$reg = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
$releaseid = $reg.releaseid
$ubr = $reg.ubr
$displayversion = $reg.displayversion

[pscustomobject]@{result = 
  switch ($releaseid) {
    '1607' { $ubr -ge '4651' } # kb5005573
    '1709' { $false } 
    '1809' { $false }
    '1903' { $false } 
    '1909' { $ubr -ge '1801' } # KB5005566
    '2004' { $ubr -ge '1288' } # kb5006670
    '2009' { $ubr -ge '1288' } # kb5006670
    default { $false }
  }
  releaseid = $releaseid
  displayversion = $displayversion
  ubr = $ubr
}
icm comp001 patchcheck.ps1 | ft

result releaseid displayversion  ubr PSComputerName RunspaceId
------ --------- --------------  --- -------------- ----------
  True 2009      21H2           2251 comp001        214ba11a-7f1b-453a-a52c-6ea59928780e

Getting whether Enterprise or Pro, in case windows 10 or 11 Enterprise reverts back by to Pro itself, which seems to be a thing:

Get-CimInstance Win32_OperatingSystem | select caption

caption
-------
Microsoft Windows 10 Enterprise
Microsoft Windows 10 Pro
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.