winutil/functions/private/Install-WinUtilWinget.ps1
Chris Titus 54a575274d
Test 2024 03 21 (#1748)
* Fix unattended answer file woes for MicroWin (#1724)

* Update applications.json

Fake app add made by linux fanboy

* Compile Winutil

* Update files

- Add detections for whether the image to be processed by MicroWin is Windows 10 or later
- Add procedure to clear the indexes ComboBox (WinForms term) every time an ISO is specified

* Update screen-install.png (#1464)

* Compile Winutil

* applications.jsonAdded Foxit Reader app and updated Foxit Editor to show the difference.

* applications.json

Added Foxit Reader app and updated Foxit Editor to show the difference.

* Compile Winutil

* Fix Broken Link and add syncthingtray (#1508)

* Compile Winutil

* Remove Nano-Removed bugged Nano package for now

* Remove Nano

-Removed bugged Nano package for now

* Compile Winutil

* tweaks and fetures tabs clean up automation from inputXML.xaml

* tweaks and fetures tabs clean up automation from inputXML.xaml

* fixed some commas in tweaks.json file

* recompile

* Update tweaks.json

* Compile Winutil

* Choosing Alternate Scartch Path and Busy Messages

* Choosing Alternate Scartch Path and Busy Messages

* Change Selected index to be pro

* Compile Winutil

* Improve detection for Professional editions

* Update files

Updated the Test-CompatibleImage function to compare against a desired version, which is useful for determining if the Specialize pass needs to be added to the unattended answer file

* Automatic conversion of ESD files

Automatically convert the install.esd file from installation media into a WIM file that can be mounted, then delete the ESD file

* pull workflow github actions (#1716)

* Update close-old-issues.yaml

* Compile Winutil

* Update close-old-issues.yaml

* Update close-old-issues.yaml

* Update close-old-issues.yaml

* Compile Winutil

---------

Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>

* Update files

Force unattended answer file to use UTF-8 encoding

---------

Co-authored-by: Chris Titus <dfm.titus@gmail.com>
Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
Co-authored-by: Samq64 <81489795+Samq64@users.noreply.github.com>
Co-authored-by: Chris Titus <contact@christitus.com>
Co-authored-by: LoopTJ <34551682+LoopTJ@users.noreply.github.com>
Co-authored-by: Roc Wang <rocwang911@gmail.com>
Co-authored-by: Jes Herring <123990927+jesjess243@users.noreply.github.com>
Co-authored-by: ogfrm <96927197+ogfrm@users.noreply.github.com>
Co-authored-by: LeeDowA <157072913+LeeDowA@users.noreply.github.com>

* add tightvnc to address issue #1718 (#1721)

* Compile Winutil

* Add 'FireFox ESR' and 'lightshot' Apps to 'application.json' File (#1720)

* Add 'FireFox ESR' and 'lightshot' Apps to 'application.json' File

* Update 'FireFox ESR' description

* Compile Winutil

* Fix typo in the Description of 'Get-Oscdimg.ps1' private function (#1743)

* Compile Winutil

* IPv6 update (#1739)

* Compile Winutil

* Change ipv6 disable method

* Compile Winutil

* IPv6 + Teredo

* Compile Winutil

* IPv6 registry

* Compile Winutil

* Update Winutil

* Compile Winutil

* Fix to original command

* Compile Winutil

---------

Co-authored-by: Joanty24 <Joanty24@users.noreply.github.com>
Co-authored-by: Chris Titus <contact@christitus.com>

* Compile Winutil

* Implement New Winget Install Method (#1738)

- Removed Get-LatestHash from Install-WinUtilWinget.ps1, replaced by Get-WinUtilWingetLatest.ps1.
- Added new Winget Install method in case of choco failing to install. Environment refresh line included.
- Get-WinUtilWingetPrerequisites added: Downloads the prerequisites required for the latest version of Winget.
- Get-WinUtilWingetLatest added: Uses the GitHub API to find the latest version of Winget and download it along with the accompanied License1.xml file.

Fixes:
- Removed --scope=machine from winget install command in Install-WinUtilProgramWinget. Non-UWP Apps fail to install if scope is set to machine. Error code: 0x80070005. More information commented in file.

* Compile Winutil

* Change order for easier launch in README and fix outdated info (#1732)

* Update README.md

* Update README.md

---------

Co-authored-by: NewCodingAI <165050080+NewCodingAI@users.noreply.github.com>

* Upgrade Fix in #1181 (#1730)

* Compile Winutil

* Fixed Ventoy drive copy typo and began conversion of DISM commands into DISM cmdlets (#1727)

* Fixed Ventoy drive copy typo

* DISM cmdlet Update (Part 1)

Began replacing basic DISM commands with cmdlets from the DISM module.

This change only affects the mount, unmount, and export operations. All other operations still use DISM

---------

Co-authored-by: Chris Titus <contact@christitus.com>

* Compile Winutil

---------

Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com>
Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
Co-authored-by: Samq64 <81489795+Samq64@users.noreply.github.com>
Co-authored-by: LoopTJ <34551682+LoopTJ@users.noreply.github.com>
Co-authored-by: Roc Wang <rocwang911@gmail.com>
Co-authored-by: Jes Herring <123990927+jesjess243@users.noreply.github.com>
Co-authored-by: ogfrm <96927197+ogfrm@users.noreply.github.com>
Co-authored-by: LeeDowA <157072913+LeeDowA@users.noreply.github.com>
Co-authored-by: Peter Gallwas <peg0252@arastudent.ac.nz>
Co-authored-by: Mr.k <mineshtine28546271@gmail.com>
Co-authored-by: Joan Solana Raduà <joansolana@proton.me>
Co-authored-by: Joanty24 <Joanty24@users.noreply.github.com>
Co-authored-by: Rux <jonathan.e.rux@gmail.com>
Co-authored-by: ModernTTY <165050080+ModernTTY@users.noreply.github.com>
Co-authored-by: NewCodingAI <165050080+NewCodingAI@users.noreply.github.com>
Co-authored-by: Justawildwolf <62820836+blusewill@users.noreply.github.com>
2024-03-28 12:39:23 -07:00

59 lines
2.8 KiB
PowerShell

function Install-WinUtilWinget {
<#
.SYNOPSIS
Installs Winget if it is not already installed.
.DESCRIPTION
This function will download the latest version of Winget and install it. If Winget is already installed, it will do nothing.
#>
Try{
Write-Host "Checking if Winget is Installed..."
if (Test-WinUtilPackageManager -Winget) {
# Checks if Winget executable exists and if the Windows Version is 1809 or higher
Write-Host "Winget Already Installed"
return
}
# Gets the computer's information
if ($null -eq $sync.ComputerInfo){
$ComputerInfo = Get-ComputerInfo -ErrorAction Stop
}
Else {
$ComputerInfo = $sync.ComputerInfo
}
if (($ComputerInfo.WindowsVersion) -lt "1809") {
# Checks if Windows Version is too old for Winget
Write-Host "Winget is not supported on this version of Windows (Pre-1809)"
return
}
if((Get-Command -Name choco -ErrorAction Ignore)) {
# Checks if Chocolatey is present (In case it didn't install properly), and installs Winget with choco, if so.
Write-Host "Chocolatey detected. Installing Winget via Chocolatey"
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget-cli"
Write-Host "Winget Installed"
Write-Output "Refreshing Environment Variables...`n"
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
}
Else {
# If Chocolatey doesn't exist, it will install Winget through more manual means.
# Used part of my own script with some modification: ruxunderscore/windows-initialization
Write-Host "Downloading Winget Prerequsites"
Get-WinUtilWingetPrerequisites
Write-Host "Downloading Winget and License File"
Get-WinUtilWingetLatest
Write-Host "Installing Winget w/ Prerequsites"
Add-AppxProvisionedPackage -Online -PackagePath $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle -DependencyPackagePath $ENV:TEMP\Microsoft.VCLibs.x64.Desktop.appx, $ENV:TEMP\Microsoft.UI.Xaml.x64.appx -LicensePath $ENV:TEMP\License1.xml
Write-Host "Winget Installed"
# Winget only needs a refresh of the environment variables to be used.
Write-Output "Refreshing Environment Variables...`n"
$ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
}
}
Catch{
throw [WingetFailedInstall]::new('Failed to install')
}
}