Skip to content

Commit 2e12176

Browse files
authored
Create Windev.ps1 loader (ChrisTitusTech#2210)
* initialize Windev branch * Formatting * more Formatting
1 parent 7d1e4a8 commit 2e12176

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

windev.ps1

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<#
2+
.SYNOPSIS
3+
This Script is used as a target for the https://christitus.com/windev alias.
4+
It queries the latest winget release (no matter if Pre-Release, Draft or Full Release) and invokes It
5+
.DESCRIPTION
6+
This Script provides a simple way to always start the bleeding edge release even if it's not yet a full release.
7+
This function should be run with administrative privileges.
8+
Because this way of recursively invoking scripts via Invoke-Expression it might very well happen that AV Programs flag this because it's a common way of mulitstage exploits to run
9+
.EXAMPLE
10+
irm https://christitus.com/windev | iex
11+
OR
12+
Run in Admin Powershell > ./windev.ps1
13+
#>
14+
15+
# Function to fetch the latest release tag from the GitHub API
16+
function Get-LatestRelease {
17+
try {
18+
$releases = Invoke-RestMethod -Uri 'https://api.github.com/repos/ChrisTitusTech/winutil/releases'
19+
$latestRelease = $releases | Select-Object -First 1
20+
return $latestRelease.tag_name
21+
} catch {
22+
Write-Host "Error fetching release data: $_" -ForegroundColor Red
23+
return $null
24+
}
25+
}
26+
27+
# Function to redirect to the latest pre-release version
28+
function RedirectToLatestPreRelease {
29+
$latestRelease = Get-LatestRelease
30+
if ($latestRelease) {
31+
$url = "https://raw.githubusercontent.com/ChrisTitusTech/winutil/$latestRelease/winutil.ps1"
32+
Invoke-RestMethod $url | Invoke-Expression
33+
} else {
34+
Write-Host 'Unable to determine latest pre-release version.' -ForegroundColor Red
35+
}
36+
}
37+
38+
# Call the redirect function
39+
40+
RedirectToLatestPreRelease

0 commit comments

Comments
 (0)