From 9401de8bc7eb72812efc6a0018fd244437d5ec0e Mon Sep 17 00:00:00 2001 From: Raphire <9938813+Raphire@users.noreply.github.com> Date: Thu, 23 May 2024 16:07:18 +0200 Subject: [PATCH] Win11Debloat now manually checks if git is installed (#59) --- Get.ps1 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Get.ps1 b/Get.ps1 index 84a6034..7cb206a 100644 --- a/Get.ps1 +++ b/Get.ps1 @@ -42,9 +42,18 @@ Write-Output "------------------------------------------------------------------ # Make sure winget is installed and is at least v1.4 if ((Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") -and ((winget -v) -replace 'v','' -gt 1.4)) { - # Install git if it isn't already installed - Write-Output "> Installing git..." - winget install git.git --accept-package-agreements --accept-source-agreements --disable-interactivity --no-upgrade + # Check if git is installed. Install git if it isn't installed yet + try + { + git | Out-Null + } + catch [System.Management.Automation.CommandNotFoundException] + { + Write-Output "> Installing git..." + winget install git.git --accept-package-agreements --accept-source-agreements --disable-interactivity --no-upgrade + + Write-Output "" + } # Navigate to user temp directory cd $env:TEMP @@ -52,8 +61,6 @@ if ((Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") -and ((winget -v) # Add default install location of git to path $env:Path += ';C:\Program Files\Git\cmd' - Write-Output "" - # Download Win11Debloat from github Write-Output "> Downloading Win11Debloat..." git clone https://github.com/Raphire/Win11Debloat/ @@ -75,5 +82,5 @@ if ((Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") -and ((winget -v) Remove-Item -LiteralPath "Win11Debloat" -Force -Recurse } else { - Write-Error "Unable to start script, Winget is not installed or outdated." + Write-Error "Unable to start script, WinGet is not installed or outdated." }