Forum Discussion

yoyojammer's avatar
yoyojammer
Copper Contributor
Jan 30, 2023

How can I check a DWORD name and use Greater Than command?

Hi all, not being a powershell expert but need help... Pushing out Desktop Runtime but finding a detection method is tricky, however a DWORD name is shown for that version in the same place in all machines so makes sense to use that. My issue is that I can write a powershell script to check that dword exists for that version in this case 6.0.13 but I want to check for version 6.0.7 and anything greater than that number but in the DWORD name rather than it's value... any ideas welcome! 🙂 Thanks

 

$DWordName = "6.0.13"

$Locations =
"HKLM:\SOFTWARE\WOW6432Node\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.WindowsDesktop.App"

foreach($location in $locations)

{

if((get-itempropertyvalue -path $location -name $DWordName) -eq "1"){write-host "Value already exists"}

write-output "installed" }

  • yoyojammer I think this should work. In my case, it outputs this:

     

    WARNING: Found old version 5.0.17 of Microsoft.WindowsDesktop.App which is not greater or equal to 6.0.13
    Found version 6.0.13 of Microsoft.WindowsDesktop.App which is greater or equal to 6.0.13
    Found version 7.0.2 of Microsoft.WindowsDesktop.App which is greater or equal to 6.0.13

     

    Code:

     

    $DWordName = "6.0.13"
    $Location = "HKLM:\SOFTWARE\WOW6432Node\dotnet\Setup\InstalledVersions\x64\sharedfx\"
    $filter = 'Microsoft.WindowsDesktop.App'
    foreach ($version in (Get-ChildItem -Path $location | Where-Object Name -match $filter).Property | Sort-Object) {
        if ($version -ge $DWordName) {
            Write-Host ("Found version {0} of {1} which is greater or equal to {2}" -f $version, $filter, $DWordName) -ForegroundColor Green
        }
        else {
            Write-Warning (("Found old version {0} of {1} which is not greater or equal to {2}" -f $version, $filter, $DWordName))
        }
    }

Resources