From 1982b934752b366fbc0673e589aa745f58e77936 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sat, 28 Jun 2025 20:38:42 -0400 Subject: [PATCH] Update StackMonkey.ps1 --- StackMonkey.ps1 | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index b093626..993b243 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -102,15 +102,21 @@ Import-Module PowerShellGet -Force -ErrorAction SilentlyContinue $ProgressPreference = 'SilentlyContinue' $ConfirmPreference = 'None' -# if NuGet isn't already available, install it non-interactively +# check if NuGet exists (no output—assigned to $nuget) +$nuget = Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue -if (-not (Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue)) { - Install-PackageProvider ` - -Name NuGet ` - -MinimumVersion 2.8.5.201 ` - -Force ` - -Confirm:$false ` - | Out-Null +if (-not $nuget) { + # install it (again, assignment suppresses the table) + $nuget = Install-PackageProvider ` + -Name NuGet ` + -MinimumVersion 2.8.5.201 ` + -Force ` + -Confirm:$false + + Write-Host "✔ Installed NuGet provider v$($nuget.Version)" -ForegroundColor Green +} +else { + Write-Host "ℹ NuGet provider already present (v$($nuget.Version))" -ForegroundColor DarkGray } # import it so Register-PSRepository / Install-Module won't prompt