UPDATED THE NUGET INSTALL PROCESS
This commit is contained in:
@@ -1659,51 +1659,43 @@ function Install-DattoRMM {
|
||||
#endregion EntryPoint: Define Invoke-ScriptMonkey
|
||||
|
||||
#region — guarantee NuGet provider is present without prompting
|
||||
# ─── NuGet + PSGallery bootstrap (safe & silent) ───
|
||||
|
||||
# ─── Top of script ───
|
||||
Import-Module PackageManagement -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
Import-Module PowerShellGet -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
# ─── ensure TLS 1.2 + no prompts ───
|
||||
# 1) Enforce TLS 1.2 and disable progress UI
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$ConfirmPreference = 'None'
|
||||
|
||||
# check if NuGet exists (no output—assigned to $nuget)
|
||||
$nuget = Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue
|
||||
# 2) Import core modules (no warnings)
|
||||
Import-Module PackageManagement -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
Import-Module PowerShellGet -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
if (-not $nuget) {
|
||||
# install it (again, assignment suppresses the table)
|
||||
Install-PackageProvider `
|
||||
-Name NuGet `
|
||||
-MinimumVersion 2.8.5.201 `
|
||||
-Force `
|
||||
-Confirm:$false
|
||||
|
||||
|
||||
# re-query just for version info
|
||||
$found = Get-PackageProvider -Name NuGet -ListAvailable
|
||||
Write-LogHybrid "Installed NuGet provider v$($found.Version)" Info Bootstrap -LogToEvent
|
||||
}
|
||||
else {
|
||||
Write-LogHybrid "NuGet provider already present (v$($found.Version))" Info Bootstrap -LogToEvent
|
||||
}
|
||||
|
||||
# now import it silently
|
||||
Import-PackageProvider -Name NuGet -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
# ensure trust PSGallery without its own output (so you don't get “untrusted repository” prompt
|
||||
# 3) Trust PSGallery if not already
|
||||
$gallery = Get-PSRepository -Name PSGallery -ErrorAction SilentlyContinue
|
||||
if ($gallery.InstallationPolicy -ne 'Trusted') {
|
||||
Set-PSRepository `
|
||||
-Name PSGallery `
|
||||
-InstallationPolicy Trusted `
|
||||
-ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
if ($gallery -and $gallery.InstallationPolicy -ne 'Trusted') {
|
||||
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -ErrorAction SilentlyContinue
|
||||
Write-LogHybrid "PSGallery marked as Trusted" Info Bootstrap -LogToEvent
|
||||
}
|
||||
|
||||
#endregion
|
||||
# 4) Ensure NuGet provider is available and installed without prompt
|
||||
$nuget = Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue
|
||||
if (-not $nuget) {
|
||||
try {
|
||||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm:$false -ErrorAction Stop
|
||||
$found = Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue
|
||||
Write-LogHybrid "Installed NuGet provider v$($found.Version)" Info Bootstrap -LogToEvent
|
||||
} catch {
|
||||
Write-LogHybrid "NuGet install failed: $($_.Exception.Message)" Error Bootstrap -LogToEvent
|
||||
}
|
||||
} else {
|
||||
Write-LogHybrid "NuGet provider already present (v$($nuget.Version))" Info Bootstrap -LogToEvent
|
||||
}
|
||||
|
||||
# 5) Import it silently (optional but safe)
|
||||
Import-PackageProvider -Name NuGet -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
#endregion guarantee NuGet provider is present without prompting
|
||||
|
||||
|
||||
#region HTTP Listener & Routing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user