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.
This commit is contained in:
2026-11-04 09:25:53 +01:00
parent 2b82dbd1f0
commit 84815eef09
+2 -1
View File
@@ -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 {