从PowerShell网站上获取最新的下载URL和软件版本

发布于 2025-01-31 03:53:02 字数 387 浏览 5 评论 0原文

我想采用该软件的最新版本,并检查系统上安装的版本,如果它是较新的安装新版本。

'''$ web = invoke-webrequest -uri“ https://www.webex.com/downloads/jabber/jabber/jabber-vdi.html” ($最新= $ web。

以获取我写的版本编号和URL,但不起作用

''($最终= $最终。 ($ downloadurl = $最终。

我也尝试过这种方式,但不起作用

'''$最新verathsversion = $最终.links.href''''

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 '''

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨落□心尘 2025-02-07 03:53:02

您可以使用链接属性来查看所有检索到的链接,然后过滤以选择“ 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

编辑结束的链接:要获得两者,也可以使用parsedhtml,例如:

(Invoke-WebRequest -Uri "https://www.webex.com/downloads/jabber/jabber-vdi.html").ParsedHtml.body.getElementsByClassName('vdi-links')[0].innerHTML -match "<LI>(\d{1,2}\.\d).*(https.*msi)"
write-host "Version $($Matches[1]) available at $($Matches[2])"

$匹配是一个自动变量,是一个自动变量,包含-match REGEX的结果。比赛中的括号定义了我们的比赛组,因此对于的等级,“&lt; li&gt;(\ d {1,2} \。\。\ d)。*(https。*msi)”

我们的第一个匹配是(\ d {1,2} \。\ d)其中\ d是任何数字,{1,2}表示匹配1或2(因此,我们可以匹配“ 9”或“ 10”),\。从字面上匹配DOT字符,

我们的第二个匹配是(https。*msi)其中。 /code>匹配任何字符,*表示匹配任何数量的事件。

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

edit: to get both, maybe use ParsedHtml like so:

(Invoke-WebRequest -Uri "https://www.webex.com/downloads/jabber/jabber-vdi.html").ParsedHtml.body.getElementsByClassName('vdi-links')[0].innerHTML -match "<LI>(\d{1,2}\.\d).*(https.*msi)"
write-host "Version $($Matches[1]) available at $($Matches[2])"

$Matches is an automatic variable which contains the result of the -match regex. The brackets in the match define our match groups, so for our regex of "<LI>(\d{1,2}\.\d).*(https.*msi)":

Our first match is (\d{1,2}\.\d) where \d is any number and {1,2} means match either 1 or 2 (so we could match "9" or "10"), \. matches the dot character literally

Our second match is (https.*msi) where . matches any character and * means match any number of occurances.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文