From 84815eef096cf8edbeec0dc4d00b566606510f99 Mon Sep 17 00:00:00 2001 From: Tomas Kracmar Date: Wed, 4 Nov 2026 09:25:53 +0100 Subject: [PATCH] fix(Test-WeakADPasswords): stop marking PSGallery as Trusted on the host Ensure-NuGetAndPSGallery silently ran Set-PSRepository PSGallery -InstallationPolicy Trusted as a side effect of installing DSInternals, permanently changing the host's module trust policy for every later Install-Module by anyone on that machine. Removed it. The operator has already confirmed the install at this point, and both install calls (Install-Module and Save-Module) pass -Force, which skips the untrusted-repository prompt for that call only. --- Test-WeakADPasswords.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Test-WeakADPasswords.ps1 b/Test-WeakADPasswords.ps1 index 1ce4d27..01a43a3 100644 --- a/Test-WeakADPasswords.ps1 +++ b/Test-WeakADPasswords.ps1 @@ -237,7 +237,8 @@ function Ensure-NuGetAndPSGallery { Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -ErrorAction Stop | Out-Null } } catch { Write-Verbose ("NuGet provider install warning: {0}" -f $_.Exception.Message) } - try { Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -ErrorAction Stop } catch { } + # PSGallery is deliberately left untrusted: the operator already confirmed this install, and + # -Force on Install-Module/Save-Module covers it without changing the host's repository policy. } function Ensure-ADModule {