mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 17:30:37 -06:00
windev script merge
This commit is contained in:
parent
d73b237550
commit
b026a0bc46
@ -41,6 +41,8 @@ param(
|
|||||||
& {
|
& {
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$IsAdmin = [bool](
|
$IsAdmin = [bool](
|
||||||
[Security.Principal.WindowsPrincipal](
|
[Security.Principal.WindowsPrincipal](
|
||||||
[Security.Principal.WindowsIdentity]::GetCurrent()
|
[Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
@ -52,12 +54,43 @@ param(
|
|||||||
# Enable TLSv1.2 for compatibility with older clients for current session
|
# Enable TLSv1.2 for compatibility with older clients for current session
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
|
||||||
|
# Function to redirect to the latest pre-release version
|
||||||
|
function Get-Latest-PreRelease-Url {
|
||||||
|
function Get-LatestRelease {
|
||||||
|
try {
|
||||||
|
$releases = Invoke-RestMethod -Uri 'https://api.github.com/repos/ChrisTitusTech/winutil/releases'
|
||||||
|
$latestRelease = $releases | Where-Object {$_.prerelease -eq $true} | Select-Object -First 1
|
||||||
|
return $latestRelease.tag_name
|
||||||
|
} catch {
|
||||||
|
Write-Host "Error fetching release data: $_" -ForegroundColor Red
|
||||||
|
return $latestRelease.tag_name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to redirect to the latest pre-release version
|
||||||
|
function RedirectToLatestPreRelease {
|
||||||
|
$latestRelease = Get-LatestRelease
|
||||||
|
|
||||||
|
if ($latestRelease) {
|
||||||
|
$url = "https://github.com/ChrisTitusTech/winutil/releases/download/$latestRelease/winutil.ps1"
|
||||||
|
} else {
|
||||||
|
Write-Host 'Unable to determine latest pre-release version.' -ForegroundColor Red
|
||||||
|
Write-Host "Using latest Full Release"
|
||||||
|
$url = "https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1"
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url
|
||||||
|
}
|
||||||
|
|
||||||
|
return RedirectToLatestPreRelease
|
||||||
|
}
|
||||||
|
|
||||||
$url = if (-not $Preview) {
|
$url = if (-not $Preview) {
|
||||||
# This must be pointing to the latest release
|
# This must be pointing to the latest stable release (Chris-Hosted)
|
||||||
"https://christitus.com/win/stable"
|
"https://christitus.com/win/stable"
|
||||||
} else {
|
} else {
|
||||||
# This must be pointing to the latest pre-release
|
# This must be pointing to the latest pre-release or the release (GitHub releases)
|
||||||
"https://christitus.com/win/preview"
|
Get-Latest-PreRelease-Url
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($IsAdmin) {
|
if ($IsAdmin) {
|
||||||
|
42
windev.ps1
42
windev.ps1
@ -1,42 +0,0 @@
|
|||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
This Script is used as a target for the https://christitus.com/win/preview alias.
|
|
||||||
It queries the latest winget release (no matter if Pre-Release, Draft or Full Release) and invokes It
|
|
||||||
.DESCRIPTION
|
|
||||||
This Script provides a simple way to always start the bleeding edge release even if it's not yet a full release.
|
|
||||||
This function should be run with administrative privileges.
|
|
||||||
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
|
|
||||||
.EXAMPLE
|
|
||||||
iex "& { $(iwr 'https://christitus.com/win/preview') }"
|
|
||||||
OR
|
|
||||||
Run in Admin Powershell > ./windev.ps1
|
|
||||||
#>
|
|
||||||
|
|
||||||
# Function to fetch the latest release tag from the GitHub API
|
|
||||||
function Get-LatestRelease {
|
|
||||||
try {
|
|
||||||
$releases = Invoke-RestMethod -Uri 'https://api.github.com/repos/ChrisTitusTech/winutil/releases'
|
|
||||||
$latestRelease = $releases | Where-Object {$_.prerelease -eq $true} | Select-Object -First 1
|
|
||||||
return $latestRelease.tag_name
|
|
||||||
} catch {
|
|
||||||
Write-Host "Error fetching release data: $_" -ForegroundColor Red
|
|
||||||
return $latestRelease.tag_name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to redirect to the latest pre-release version
|
|
||||||
function RedirectToLatestPreRelease {
|
|
||||||
$latestRelease = Get-LatestRelease
|
|
||||||
if ($latestRelease) {
|
|
||||||
$url = "https://github.com/ChrisTitusTech/winutil/releases/download/$latestRelease/winutil.ps1"
|
|
||||||
} else {
|
|
||||||
Write-Host 'Unable to determine latest pre-release version.' -ForegroundColor Red
|
|
||||||
Write-Host "Using latest Full Release"
|
|
||||||
$url = "https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1"
|
|
||||||
}
|
|
||||||
Invoke-RestMethod $url | Invoke-Expression
|
|
||||||
}
|
|
||||||
|
|
||||||
# Call the redirect function
|
|
||||||
|
|
||||||
RedirectToLatestPreRelease
|
|
Loading…
Reference in New Issue
Block a user