-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The winget.ps1 script is currently not working. Microsoft is still doing work on this front so I'm going to wait until the dust settles here. If you need non-interactive installation of WinGet now then see here: https://github.com/asheroto/winget-installer/blob/master/winget-install.ps1 WinGet GitHub issues to track: microsoft/winget-cli#401 microsoft/winget-cli#2434 Also, perhaps MSIX Core so we can get Windows 7 support: https://learn.microsoft.com/en-us/windows/msix/msix-core/msixcore However, that's only MSIX, MS isn't targeting WinGet for below Windows 10 1809 (but maybe someone will build a small compatability layer): microsoft/winget-cli#1686 (comment)
- Loading branch information
1 parent
9f68dd9
commit 854f1f9
Showing
4 changed files
with
98 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
.SYNOPSIS | ||
Install Chocolatey and specified packages | ||
.PARAMETER Packages | ||
Comma-separated list of packages to install (see available packages at: https://chocolatey.org/packages) | ||
Comma-separated list of packages to install | ||
#> | ||
|
||
# Copyright (C) 2019 Elliot Killick <[email protected]> | ||
|
@@ -15,7 +15,10 @@ Param ( | |
$host.UI.RawUI.WindowTitle = $PSCommandPath | ||
|
||
# Force Powershell 2 to use TLS 1.2 | ||
[System.Net.ServicePointManager]::SecurityProtocol = [Enum]::ToObject([System.Net.SecurityProtocolType], 3072) | ||
if ([System.Net.SecurityProtocolType]::Tls12 -eq $null) { | ||
Write-Host "Enabling TLS 1.2 for PowerShell 2 (please ignore Chocolatey if it claims that TLS 1.0 is in use)..." | ||
[System.Net.ServicePointManager]::SecurityProtocol = [Enum]::ToObject([System.Net.SecurityProtocolType], 3072) | ||
} | ||
|
||
# https://chocolatey.org/install | ||
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<# | ||
.SYNOPSIS | ||
Install WinGet (if required) and specified packages | ||
.PARAMETER Packages | ||
Comma-separated list of packages to install | ||
#> | ||
|
||
# Copyright (C) 2023 Elliot Killick <[email protected]> | ||
# Licensed under the MIT License. See LICENSE file for details. | ||
|
||
Param ( | ||
[Parameter(Mandatory=$true)][String[]]$Packages | ||
) | ||
|
||
$host.UI.RawUI.WindowTitle = $PSCommandPath | ||
|
||
if (!(Get-Command -ErrorAction SilentlyContinue winget)) { | ||
# Force Powershell 2 to use TLS 1.2 | ||
if ([System.Net.SecurityProtocolType]::Tls12 -eq $null) { | ||
Write-Host "Enabling TLS 1.2 for PowerShell 2..." | ||
[System.Net.ServicePointManager]::SecurityProtocol = [Enum]::ToObject([System.Net.SecurityProtocolType], 3072) | ||
} | ||
|
||
$wc = New-Object System.Net.WebClient | ||
|
||
# GitHub API always blocks empty user agents (default for WebClient) | ||
# Set a common user agent to avoid figerprinting | ||
if ([Microsoft.PowerShell.Commands.PSUserAgent] -ne $null) { | ||
$wc.Headers.Add('User-Agent', [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome) | ||
else { | ||
# PowerShell 2 | ||
# Set user agent of most up-to-date Internet Explorer (before EOL) on Windows 7 | ||
# Even the 64-bit iexplore.exe in "C:\Program Files" has a "WOW64" user agent | ||
$wc.Headers.Add('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko') | ||
} | ||
|
||
# Download and extract WinGet MSIX bundle link | ||
# We could parse the JSON, but this is more secure | ||
$wc.DowloadString('https://api.github.com/repos/microsoft/winget-cli/releases/latest') -match 'https://github.com/microsoft/winget-cli/releases/download/v[0-9.]+/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle' | ||
$url = matches[0] | ||
|
||
# Create temporary file | ||
$file = [IO.Path]::GetTempFileName() | ||
|
||
(New-Object System.Net.WebClient).DownloadFile($url, $file) | ||
|
||
Add-AppxPackage -Path $file | ||
|
||
Remove-Item -Path $file | ||
} | ||
|
||
winget install --accept-source-agreements --accept-package-agreements --exact --id $Packages | ||
|
||
# Install from terminal: https://github.com/microsoft/winget-cli/issues/2222 | ||
# MSIX Core: https://learn.microsoft.com/en-us/windows/msix/msix-core/msixcore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters