-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriftDetect.WinServer.psm1
More file actions
84 lines (73 loc) · 2.42 KB
/
DriftDetect.WinServer.psm1
File metadata and controls
84 lines (73 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#Requires -Version 7.0
<#
.SYNOPSIS
DriftDetect.WinServer - Windows Server 2022/2025 configuration drift detection module.
.DESCRIPTION
Root module file that loads all classes, private functions, and public functions.
This module provides comprehensive drift detection for Windows Server environments
using hash-based change tracking and severity scoring.
Supports both local and remote collection via PowerShell Remoting.
#>
$ErrorActionPreference = 'Stop'
# Get module root path
$ModuleRoot = $PSScriptRoot
# Load Classes (order matters - base classes first)
$classLoadOrder = @(
'EntityBase.ps1'
'CollectorBase.ps1'
'SystemCollector.ps1'
'ServiceCollector.ps1'
'FeatureCollector.ps1'
'NetworkCollector.ps1'
'StorageCollector.ps1'
'FirewallCollector.ps1'
'ScheduledTaskCollector.ps1'
'LocalUserGroupCollector.ps1'
'GroupPolicyCollector.ps1'
'RegistryCollector.ps1'
'DomainCollector.ps1'
'Snapshot.ps1'
'DriftEngine.ps1'
)
Write-Verbose "Loading DriftDetect.WinServer classes..."
foreach ($className in $classLoadOrder) {
$classPath = Join-Path $ModuleRoot "Classes\$className"
if (Test-Path $classPath) {
. $classPath
Write-Verbose " Loaded: $className"
}
else {
Write-Warning "Class file not found: $classPath"
}
}
# Load Private functions
Write-Verbose "Loading private functions..."
$privatePath = Join-Path $ModuleRoot 'Private'
if (Test-Path $privatePath) {
Get-ChildItem -Path $privatePath -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
try {
. $_.FullName
Write-Verbose " Loaded: $($_.Name)"
}
catch {
Write-Warning "Failed to load private function $($_.Name): $_"
}
}
}
# Load Public functions
Write-Verbose "Loading public functions..."
$publicPath = Join-Path $ModuleRoot 'Public'
if (Test-Path $publicPath) {
Get-ChildItem -Path $publicPath -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue | ForEach-Object {
try {
. $_.FullName
Write-Verbose " Loaded: $($_.Name)"
}
catch {
Write-Warning "Failed to load public function $($_.Name): $_"
}
}
}
# Export public functions
Export-ModuleMember -Function 'New-WSSnapshot', 'Compare-WSSnapshot', 'Export-WSDriftReport', 'Get-WSSnapshot'
Write-Verbose "DriftDetect.WinServer module loaded successfully"