Third root script converted. This one cannot be exercised end-to-end
without a Windows host and a domain, so the move is mechanical: the
split used the script's own AST (function and statement line ranges),
and a line-by-line comparison ignoring indentation shows only the
intended differences below.
- Script body -> src/Elysium/Public/Test-ElysiumPasswordQuality.ps1
(exported, [CmdletBinding()], comment-based help).
- Its helpers -> Private/PasswordQuality.ps1; the inner
Test-WeakADPasswords function is renamed Invoke-WeakPasswordTest.
Several of them read variables the cmdlet sets ($runningInPSCore,
$onWindows, $reportPathBase, $timestamp, $header, $footer) through
dynamic scoping, exactly as they read script-level variables before;
the file header says so, and they become parameters in a later step.
- Get-DomainDetailsFromSettings -> Private/Settings.ps1.
- The inline KHDB path resolution becomes Get-KhdbPath (same
semantics); transcript via the shared helper; $scriptRoot ->
$InstallRoot.
- `exit` / `exit 0` -> `return`: inside a module function, exit would
end the operator's whole PowerShell session.
- Dropped the script-level $PSDefaultParameterValues /
$OutputEncoding block: both Out-File calls already pass
-Encoding utf8, nothing else writes files or calls native commands,
and in a cmdlet it would mutate the caller's session-global table.
Dropped the forced $VerbosePreference = 'SilentlyContinue', so
-Verbose now works.
ActiveDirectory/DSInternals are now imported from inside the module,
so they load into the module's session state instead of the global
one. Checked with stand-in modules: Get-Module (used by
Import-CompatModule and the DSInternals version check) still sees
them from module code, their commands are callable from module code,
and nothing leaks into the caller's session.
Test-WeakADPasswords.ps1 is now a thin wrapper (relaunch under
powershell.exe, import module, call the cmdlet).
Tests: domain list parsing; Resolve-DSInternalsWeakHashFile on a
clean file (passed through), a legacy file (case, HASH:count and
duplicates normalized into a temp file), and unsorted/malformed files.
22/22 Pester tests pass. On macOS the cmdlet runs through settings
and domain parsing (with -Verbose) up to its Windows-only guard and
writes its transcript. Needs a Windows run against a domain.