Created
October 30, 2022 16:53
-
-
Save BOAScripts/31aafe092dbc6cee4d547d25c48e94fe to your computer and use it in GitHub Desktop.
Find id of latest Python version on winget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Pythons3Search = winget search 'Python.3' | |
| $PythonResults = $Pythons3Search[3..$Pythons3Search.Length] | |
| [version]$ver ='3.0' | |
| $node = '' | |
| Foreach ($entry in $PythonResults) { | |
| $entryVer = [version]$entry.replace(' ',';').split(';')[2] | |
| $entryid = $entry.replace(' ',';').split(';')[1] | |
| if ($ver -lt $entryVer ){ | |
| $ver = $entryVer | |
| $node = $entryid | |
| } | |
| } | |
| Write-Host $node |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment