mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-07-26 11:49:17 +00:00
95789953a8
* Updated copyright year from 2024 to 2025. * Incremented `ModuleVersion` from `1.1.9` to `1.1.10`. * Updated dependencies' module versions: - `PSWriteColor` from `1.0.1` to `1.0.3` - `PSSharedGoods` from `0.0.301` to `0.0.312` - `ADEssentials` from `0.0.226` to `0.0.267` * Refactored `Foreach` to `foreach` for consistency in `GPOZaurr.psm1`.
54 lines
2.3 KiB
PowerShell
54 lines
2.3 KiB
PowerShell
#Get public and private function definition files.
|
|
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue -Recurse )
|
|
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue -Recurse )
|
|
|
|
$AssemblyFolders = Get-ChildItem -Path $PSScriptRoot\Lib -Directory -ErrorAction SilentlyContinue
|
|
if ($AssemblyFolders.BaseName -contains 'Standard') {
|
|
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Standard\*.dll -ErrorAction SilentlyContinue )
|
|
} else {
|
|
if ($PSEdition -eq 'Core') {
|
|
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Core\*.dll -ErrorAction SilentlyContinue )
|
|
} else {
|
|
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Default\*.dll -ErrorAction SilentlyContinue )
|
|
}
|
|
}
|
|
$FoundErrors = @(
|
|
foreach ($Import in @($Assembly)) {
|
|
try {
|
|
Add-Type -Path $Import.Fullname -ErrorAction Stop
|
|
} catch [System.Reflection.ReflectionTypeLoadException] {
|
|
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
|
|
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
|
|
foreach ($E in $LoaderExceptions) {
|
|
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
|
|
}
|
|
$true
|
|
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
|
|
} catch {
|
|
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
|
|
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
|
|
foreach ($E in $LoaderExceptions) {
|
|
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
|
|
}
|
|
$true
|
|
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
|
|
}
|
|
}
|
|
#Dot source the files
|
|
foreach ($Import in @($Private + $Public)) {
|
|
try {
|
|
. $Import.Fullname
|
|
} catch {
|
|
Write-Error -Message "Failed to import functions from $($import.Fullname): $_"
|
|
$true
|
|
}
|
|
}
|
|
)
|
|
|
|
if ($FoundErrors.Count -gt 0) {
|
|
$ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName
|
|
Write-Warning "Importing module $ModuleName failed. Fix errors before continuing."
|
|
break
|
|
}
|
|
|
|
Export-ModuleMember -Function '*' -Alias '*' |