Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: PowerShell Core Incompatibility #379 [Feature Request]: Winget… #385

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Bug]: PowerShell Core Incompatibility #379 [Feature Request]: Winget…
… update #380 VC_redist vs VCLibs VC_redist vs VCLibs #381 [Bug]: Windows Sandbox incompatibility #384
KnifMelti committed Aug 27, 2023
commit 9ef2768fb53db00fbdcca6f12a06a1603a654686
70 changes: 53 additions & 17 deletions Winget-AutoUpdate-Install.ps1
Original file line number Diff line number Diff line change
@@ -155,23 +155,23 @@ function Install-Prerequisites {
else {
$OSArch = "x86"
}
Write-host "-> Downloading VC_redist.$OSArch.exe..."
Write-host "Downloading VC_redist.$OSArch.exe..."
$SourceURL = "https://aka.ms/vs/17/release/VC_redist.$OSArch.exe"
$Installer = $WingetUpdatePath + "\VC_redist.$OSArch.exe"
$Installer = "$PSScriptRoot\VC_redist.$OSArch.exe"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest $SourceURL -UseBasicParsing -OutFile (New-Item -Path $Installer -Force)
Write-host "-> Installing VC_redist.$OSArch.exe..."
Write-host "Installing VC_redist.$OSArch.exe..."
Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait
Remove-Item $Installer -ErrorAction Ignore
Write-host "-> MS Visual C++ 2015-2022 installed successfully" -ForegroundColor Green
Remove-Item $Installer -Force -ErrorAction Ignore
Write-host "MS Visual C++ 2015-2022 installed successfully" -ForegroundColor Green
}
catch {
Write-host "-> MS Visual C++ 2015-2022 installation failed." -ForegroundColor Red
Write-host "MS Visual C++ 2015-2022 installation failed." -ForegroundColor Red
Start-Sleep 3
}
}
else {
Write-host "-> MS Visual C++ 2015-2022 will not be installed." -ForegroundColor Magenta
Write-host "MS Visual C++ 2015-2022 will not be installed." -ForegroundColor Magenta
}
}
else {
@@ -181,29 +181,65 @@ function Install-Prerequisites {

function Install-WinGet {

Write-Host "`nChecking if Winget is installed" -ForegroundColor Yellow
Write-Host "`nChecking if Winget is installed/up to date..." -ForegroundColor Yellow

#Check Package Install
$TestWinGet = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.DesktopAppInstaller" }
#Check Winget Package Installed version
$TestWinGet = Get-AppXPackage -Name 'Microsoft.DesktopAppInstaller'

#Current: v1.5.1881 = 1.20.1881.0 = 2023.707.2257.0
If ([Version]$TestWinGet.Version -ge "2023.707.2257.0") {
#Current: v1.5.2201 = 1.20.2201.0
If ([Version]$TestWinGet.Version -ge "1.20.2201.0") {

Write-Host "WinGet is Installed" -ForegroundColor Green
Write-Host "WinGet is installed/up to date" -ForegroundColor Green

}
Else {

#Check if Microsoft UI Xaml 2.7.0 is installed
if (!(Get-AppxPackage -Name 'Microsoft.UI.Xaml.2.7')) {
try {
#Install Microsoft UI Xaml 2.7.0
Write-host "Downloading Microsoft UI Xaml 2.7.0..."
$UiXamlUrl = "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0"
$UiXamlZip = "$PSScriptRoot\Microsoft.UI.XAML.2.7.zip"
Invoke-RestMethod -Uri $UiXamlUrl -OutFile $UiXamlZip
Expand-Archive -Path $UiXamlZip -DestinationPath "$PSScriptRoot\extracted" -Force
Add-AppxPackage -Path "$PSScriptRoot\extracted\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx"
Remove-Item -Path $UiXamlZip -Force -ErrorAction Ignore
Remove-Item -Path "$PSScriptRoot\extracted" -Force -Recurse -ErrorAction Ignore
Write-host "Microsoft UI Xaml 2.7.0 installed successfully" -ForegroundColor Green
}
catch {
Write-host "Microsoft UI Xaml 2.7.0 installation failed." -ForegroundColor Red
}
}

#Check if Microsoft VCLibs x64 14.00 is installed
if (!(Get-AppxPackage -Name 'Microsoft.VCLibs.140.00.UWPDesktop')) {
try {
#Install
Write-host "Downloading Microsoft VCLibs x64 14.00..."
$VCLibsUrl = "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx"
$VCLibsFile = "$PSScriptRoot\Microsoft.VCLibs.x64.14.00.Desktop.appx"
Invoke-RestMethod -Uri $VCLibsUrl -OutFile $VCLibsFile
Add-AppxPackage -Path $VCLibsFile
Remove-Item -Path $VCLibsFile -Force -ErrorAction Ignore
Write-host "Microsoft VCLibs x64 14.00 installed successfully" -ForegroundColor Green
}
catch {
Write-host "Microsoft VCLibs x64 14.00 installation failed." -ForegroundColor Red
}
}

#Download WinGet MSIXBundle
Write-Host "-> Not installed. Downloading WinGet..."
$WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.5.1881/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
Write-Host "Downloading Winget MSIXBundle for App Installer..."
$WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.5.2201/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile($WinGetURL, "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle")

#Install WinGet MSIXBundle
try {
Write-Host "-> Installing Winget MSIXBundle for App Installer..."
Add-AppxProvisionedPackage -Online -PackagePath "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null
Write-Host "Installing Winget MSIXBundle for App Installer..."
Add-AppxPackage -Path "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" | Out-Null
Write-Host "Installed Winget MSIXBundle for App Installer" -ForegroundColor Green
}
catch {
52 changes: 9 additions & 43 deletions Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1
Original file line number Diff line number Diff line change
@@ -16,62 +16,28 @@ function Invoke-PostUpdateActions {
New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ItemType SymbolicLink -Value "$WorkingDir\logs\install.log" -Force -ErrorAction SilentlyContinue | Out-Null
}

Write-ToLog "-> Checking prerequisites..." "yellow"
#Check Winget Package Installed version
Write-ToLog "-> Checking if Winget is installed/up to date"
$TestWinGet = Get-AppXPackage -Name 'Microsoft.DesktopAppInstaller'

#Check if Visual C++ 2019 or 2022 installed
$Visual2019 = "Microsoft Visual C++ 2015-2019 Redistributable*"
$Visual2022 = "Microsoft Visual C++ 2015-2022 Redistributable*"
$path = Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.GetValue("DisplayName") -like $Visual2019 -or $_.GetValue("DisplayName") -like $Visual2022 }
#Current: v1.5.2201 = 1.20.2201.0
If ([Version]$TestWinGet.Version -ge "1.20.2201.0") {

#If not installed, install
if (!($path)) {
try {
if ((Get-CimInStance Win32_OperatingSystem).OSArchitecture -like "*64*") {
$OSArch = "x64"
}
else {
$OSArch = "x86"
}
Write-ToLog "-> Downloading VC_redist.$OSArch.exe..."
$SourceURL = "https://aka.ms/vs/17/release/VC_redist.$OSArch.exe"
$Installer = "$($WAUConfig.InstallLocation)\VC_redist.$OSArch.exe"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest $SourceURL -UseBasicParsing -OutFile (New-Item -Path $Installer -Force)
Write-ToLog "-> Installing VC_redist.$OSArch.exe..."
Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait
Remove-Item $Installer -ErrorAction Ignore
Write-ToLog "-> MS Visual C++ 2015-2022 installed successfully" "green"
}
catch {
Write-ToLog "-> MS Visual C++ 2015-2022 installation failed." "red"
}
}
else {
Write-ToLog "-> Prerequisites checked. OK" "green"
}

#Check Package Install
Write-ToLog "-> Checking if Winget is installed/up to date" "yellow"
$TestWinGet = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.DesktopAppInstaller" }

#Current: v1.5.1881 = 1.20.1881.0 = 2023.707.2257.0
If ([Version]$TestWinGet.Version -ge "2023.707.2257.0") {

Write-ToLog "-> WinGet is Installed/up to date" "green"
Write-ToLog "-> WinGet is installed/up to date" "green"

}
Else {

#Download WinGet MSIXBundle
Write-ToLog "-> Not installed/up to date. Downloading WinGet..."
$WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.5.1881/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
Write-ToLog "-> Downloading Winget MSIXBundle for App Installer..."
$WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v1.5.2201/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile($WinGetURL, "$($WAUConfig.InstallLocation)\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle")

#Install WinGet MSIXBundle
try {
Write-ToLog "-> Installing Winget MSIXBundle for App Installer..."
Add-AppxProvisionedPackage -Online -PackagePath "$($WAUConfig.InstallLocation)\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null
Add-AppxPackage -Path "$($WAUConfig.InstallLocation)\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" | Out-Null
Write-ToLog "-> Installed Winget MSIXBundle for App Installer" "green"
}
catch {