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.
36 lines
1.6 KiB
PowerShell
36 lines
1.6 KiB
PowerShell
##################################################
|
|
## ____ ___ ____ _____ _ _ _____ _____ ##
|
|
## / ___/ _ \| _ \| ____| | \ | | ____|_ _| ##
|
|
## | | | | | | |_) | _| | \| | _| | | ##
|
|
## | |__| |_| | _ <| |___ _| |\ | |___ | | ##
|
|
## \____\__\_\_| \_\_____(_)_| \_|_____| |_| ##
|
|
## Move fast and fix things. ##
|
|
##################################################
|
|
## Project: Elysium ##
|
|
## File: Test-WeakADPasswords.ps1 ##
|
|
## Support: support@cqre.net ##
|
|
##################################################
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Weak AD password finder component of Elysium tool.
|
|
|
|
.DESCRIPTION
|
|
This script will test the passwords of selected domain (defined in ElysiumSettings.txt) using DSInternals' Test-PasswordQuality cmdlet. It writes its output to a report file which is meant to be shared with the internal security team. The report now includes UPNs for each account mentioned.
|
|
|
|
Thin wrapper around the Test-ElysiumPasswordQuality cmdlet in src/Elysium, kept so existing
|
|
invocations and the menu keep working.
|
|
#>
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
Set-StrictMode -Version Latest
|
|
|
|
[string]$commonHelper = Join-Path -Path $PSScriptRoot -ChildPath 'Elysium.Common.ps1'
|
|
if (-not (Test-Path -LiteralPath $commonHelper)) { throw "Common helper not found at $commonHelper" }
|
|
. $commonHelper
|
|
Restart-WithWindowsPowerShellIfAvailable -BoundParameters $PSBoundParameters -UnboundArguments $MyInvocation.UnboundArguments
|
|
|
|
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'src/Elysium/Elysium.psd1') -Force
|
|
Test-ElysiumPasswordQuality
|
|
Write-Host "Script execution completed."
|