Even if you run Get-ComputerInfo in Powershell on Windows 11 it will return Windows 10 as the WindowsProductName, since 11 is not that different than 10 internally.
I would think you would have to maintain a list of build numbers (like for example at https://www.gaijin.at/en/infos/windows-version-numbers) and then look at the CurrentBuild value in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
So anything > 22000 is Windows 11, for example.