Score:0

windows bat needs to determine the version of the msql odbc library

cg flag

Hi I need to build a bat possible power shell on standard windows 10 instance.
I need a programmatic way to set an environment variable with the version string of the latest msodbcsql library at https://packages.microsoft.com/rhel/8/prod/

the current latest version is https://packages.microsoft.com/rhel/8/prod/msodbcsql17-17.8.1.2-1.x86_64.rpm but this changes every couple of months.

I thought of something like the following PSEUDO CODE

set msodbcver=Invoke-WebRequest -Uri  https://packages.microsoft.com/rhel/8/prod/ | grep msodbcsq | sort 

but my windows system cannot find Invoke-WebRequest in either cmd.exe or powershell. Yes I am a unix guy trying to figure out equivilent MS scripting

us flag
Which version of Windows is this? Invoke-WebRequest has been in Powershell since v3. If you can post the contents of `$PSVersionTable` in the question that might help. Don't bother trying to do this in batch/cmd by the way. Powershell is the way to do it.
Score:1
us flag

If you are running a modern version of Powershell (v3 or above) you can do this with:

$env:msodbcver = (Invoke-WebRequest -Uri https://packages.microsoft.com/rhel/8/prod/).Links.Href | Select-string msodbcsq | Sort-Object -Descending | Select-Object -First 1
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.