Home > Mobile >  getting the latest download url and version of a software from a website with powershell
getting the latest download url and version of a software from a website with powershell

Time:05-23

I want to take the take the latest version of the software and check with the version that is installed on system if it is newer install the new version .

''' $web = Invoke-WebRequest -Uri "https://www.webex.com/downloads/jabber/jabber-vdi.html" ( $latest = $web.AllElements | Where-Object {$_.TagName -eq "li"} | Select-String "Jabber Windows client" | Select -first 1 )'''

for taking the version number and url I've wrote these but does not work

''' ( $latestversion = $latest.Context | Select-String -pattern "\d\d.\d") ( $downloadUrl=$latest.Context | Select-String -pattern "\w.msi" )'''

also I have tried this way but does not work

'''$latestversion = $latest.links.href '''

CodePudding user response:

You can use the Links property to view all retrieved links, then filter it to select only those ending with "msi"

(Invoke-WebRequest -Uri "https://www.webex.com/downloads/jabber/jabber-vdi.html").Links | Where-Object href -like '*msi' | select -First 1 | select -expand href
  • Related