-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourceForgeReleases.ps1
More file actions
24 lines (23 loc) · 980 Bytes
/
Copy pathSourceForgeReleases.ps1
File metadata and controls
24 lines (23 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Set the SourceForge "latest" URL for the project
# $latestUrl = 'https://sourceforge.net/projects/phppgadmin/files/latest/download'
$latestUrl = 'https://sourceforge.net/projects/winscp/files/latest/download'
# Send a web request and follow the redirect to get the real download URL
try {
$response = Invoke-WebRequest -Uri $latestUrl -MaximumRedirection 0 -ErrorAction Stop
$downloadUrl = $response.links.'data-release-url' | Select-Object -First 1
if (-not $downloadUrl) {
throw 'Download URL not found.'
}
# Remove everything after and including '?ts='
$cleanUrl = $downloadUrl -replace '\?ts=.*', ''
# Extract the version number (e.g., 6.5)
if ($cleanUrl -match '/WinSCP/([^/]+)/') {
$version = $matches[1]
} else {
$version = 'Unknown'
}
Write-Output "Latest version: $version"
Write-Output "Clean download URL: $cleanUrl"
} catch {
Write-Output 'Failed to retrieve the latest download URL.'
}