Skip to content

Commit 0573683

Browse files
fix(module): 🐛 Update module metadata and improve error handling
* Updated `ModuleVersion` to `1.0.2` and adjusted `RequiredModules` versions. * Added `Description` field to provide clarity on module functionality. * Enhanced error handling during assembly loading and function importing.
1 parent 690f96c commit 0573683

2 files changed

Lines changed: 88 additions & 86 deletions

File tree

ADEssentials.psd1

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
@{
2-
AliasesToExport = @('Get-WinDNSServerIP', 'Get-WinDnsIPAddresses', 'Get-WinDNSRecords', 'Get-WinDnsServerZones', 'Get-WinDNSZones', 'Get-WinADForestObjectsConflict', 'Get-WinADRoles', 'Get-WinADDomainRoles', 'Get-WinADSubnet', 'Get-WinADForestSubnets', 'Get-WinADPriviligedObjects', 'Get-WinADForestTombstoneLifetime', 'Get-WinADTrusts', 'Get-WinADUsersFP', 'Set-WinDNSServerIP', 'Show-WinADCriticalGroups', 'Show-ADGroupMember', 'Show-ADGroupMemberOf', 'Show-WinADSubnets', 'Show-WinADSiteCoverage', 'Show-ADTrust', 'Show-ADTrusts', 'Show-WinADTrusts', 'Sync-DomainController')
3-
Author = 'Przemyslaw Klys'
4-
CmdletsToExport = @()
5-
CompanyName = 'Evotec'
6-
CompatiblePSEditions = @('Desktop', 'Core')
7-
Copyright = '(c) 2011 - 2026 Przemyslaw Klys @ Evotec. All rights reserved.'
8-
Description = 'Helper module for Active Directory with lots of useful functions that simplify supporting Active Directory.'
9-
FunctionsToExport = @('Add-ADACL', 'Compare-PingCastleReport', 'Compare-WinADGlobalCatalogObjects', 'Convert-ADSecurityDescriptor', 'Copy-ADOUSecurity', 'Disable-ADACLInheritance', 'Enable-ADACLInheritance', 'Export-ADACLObject', 'Find-WinADObjectDifference', 'Get-ADACL', 'Get-ADACLOwner', 'Get-DNSServerIP', 'Get-PingCastleReport', 'Get-WinADACLConfiguration', 'Get-WinADACLForest', 'Get-WinADBitlockerLapsSummary', 'Get-WinADBrokenProtectedFromDeletion', 'Get-WinADComputerACLLAPS', 'Get-WinADComputers', 'Get-WinADDelegatedAccounts', 'Get-WinADDFSHealth', 'Get-WinADDFSTopology', 'Get-WinADDHCP', 'Get-WinADDHCPHealthCheck', 'Get-WinADDHCPSummary', 'Get-WinADDiagnostics', 'Get-WinADDnsInformation', 'Get-WinADDnsIPAddresses', 'Get-WinADDnsRecords', 'Get-WinADDnsServerForwarder', 'Get-WinADDnsServerScavenging', 'Get-ADWinDnsServerZones', 'Get-WinADDNSZones', 'Get-WinADDomain', 'Get-WinADDomainControllerGenerationId', 'Get-WinADDomainControllerNetLogonSettings', 'Get-WinADDomainControllerNTDSSettings', 'Get-WinADDomainControllerOption', 'Get-WinADDuplicateObject', 'Get-WinADDuplicateSPN', 'Get-WinADForest', 'Get-WinADForestControllerInformation', 'Get-WinADForestOptionalFeatures', 'Get-WinADForestReplication', 'Get-WinADForestReplicationSummary', 'Get-WinADForestRoles', 'Get-WinADForestSchemaDetails', 'Get-WinADForestSchemaProperties', 'Get-WinADForestSites', 'Get-WinADForestSubnet', 'Get-WinADGroupMember', 'Get-WinADGroupMemberOf', 'Get-WinADGroups', 'Get-WinADKerberosAccount', 'Get-WinADLastBackup', 'Get-WinADLDAPBindingsSummary', 'Get-WinADLDAPSummary', 'Get-WinADLMSettings', 'Get-WinADObject', 'Get-WinADOrganization', 'Get-WinADPasswordPolicy', 'Get-WinADPrivilegedObjects', 'Get-WinADProtocol', 'Get-WinADProxyAddresses', 'Get-WinADServiceAccount', 'Get-WinADSharePermission', 'Get-WinADSIDHistory', 'Get-WinADSiteConnections', 'Get-WinADSiteCoverage', 'Get-WinADSiteLinks', 'Get-WinADSiteOptions', 'Get-WinADTombstoneLifetime', 'Get-WinADTrust', 'Get-WinADTrustLegacy', 'Get-WinADUserPrincipalName', 'Get-WinADUsers', 'Get-WinADUsersForeignSecurityPrincipalList', 'Get-WinADWellKnownFolders', 'Invoke-ADEssentials', 'Invoke-PingCastle', 'Invoke-WinADDHCPHealthCheck', 'New-ADACLObject', 'New-ADSite', 'Remove-ADACL', 'Remove-WinADDFSTopology', 'Remove-WinADDuplicateObject', 'Remove-WinADSharePermission', 'Rename-WinADUserPrincipalName', 'Repair-WinADACLConfigurationOwner', 'Repair-WinADBrokenProtectedFromDeletion', 'Repair-WinADEmailAddress', 'Repair-WinADForestControllerInformation', 'Request-ChangePasswordAtLogon', 'Request-DisableOnAccountExpiration', 'Restore-ADACLDefault', 'Set-ADACL', 'Set-ADACLInheritance', 'Set-ADACLOwner', 'Set-DnsServerIP', 'Set-WinADDiagnostics', 'Set-WinADDomainControllerNetLogonSettings', 'Set-WinADDomainControllerOption', 'Set-WinADForestACLOwner', 'Set-WinADReplication', 'Set-WinADReplicationConnections', 'Set-WinADShare', 'Set-WinADTombstoneLifetime', 'Show-WinADDHCPSummary', 'Show-WinADDNSRecords', 'Show-WinADForestReplicationSummary', 'Show-WinADGroupCritical', 'Show-WinADGroupMember', 'Show-WinADGroupMemberOf', 'Show-WinADKerberosAccount', 'Show-WinADLdapSummary', 'Show-WinADObjectDifference', 'Show-WinADOrganization', 'Show-WinADSIDHistory', 'Show-WinADSites', 'Show-WinADSitesCoverage', 'Show-WinADTrust', 'Show-WinADUserSecurity', 'Sync-WinADDomainController', 'Test-ADDomainController', 'Test-ADRolesAvailability', 'Test-ADSiteLinks', 'Test-DNSNameServers', 'Test-FSMORolesAvailability', 'Test-LDAP', 'Test-WinADDNSResolving', 'Test-WinADObjectReplicationStatus', 'Test-WinADVulnerableSchemaClass', 'Update-LastLogonTimestamp')
10-
GUID = '9fc9fd61-7f11-4f4b-a527-084086f1905f'
11-
ModuleVersion = '1.0.1'
12-
PowerShellVersion = '5.1'
13-
PrivateData = @{
14-
PSData = @{
15-
ProjectUri = 'https://github.com/EvotecIT/ADEssentials'
16-
RequireLicenseAcceptance = $false
17-
Tags = @('Windows', 'ActiveDirectory')
18-
}
19-
}
20-
RequiredModules = @(@{
21-
Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'
22-
ModuleName = 'PSSharedGoods'
23-
ModuleVersion = '0.0.312'
24-
}, @{
25-
Guid = 'a7bdf640-f5cb-4acf-9de0-365b322d245c'
26-
ModuleName = 'PSWriteHTML'
27-
ModuleVersion = '1.38.0'
28-
}, @{
29-
Guid = '5df72a79-cdf6-4add-b38d-bcacf26fb7bc'
30-
ModuleName = 'PSEventViewer'
31-
ModuleVersion = '1.0.22'
32-
})
33-
RootModule = 'ADEssentials.psm1'
1+
@{
2+
AliasesToExport = @('Get-WinDNSServerIP', 'Get-WinDnsIPAddresses', 'Get-WinDNSRecords', 'Get-WinDnsServerZones', 'Get-WinDNSZones', 'Get-WinADForestObjectsConflict', 'Get-WinADRoles', 'Get-WinADDomainRoles', 'Get-WinADSubnet', 'Get-WinADForestSubnets', 'Get-WinADPriviligedObjects', 'Get-WinADForestTombstoneLifetime', 'Get-WinADTrusts', 'Get-WinADUsersFP', 'Set-WinDNSServerIP', 'Show-WinADCriticalGroups', 'Show-ADGroupMember', 'Show-ADGroupMemberOf', 'Show-WinADSubnets', 'Show-WinADSiteCoverage', 'Show-ADTrust', 'Show-ADTrusts', 'Show-WinADTrusts', 'Sync-DomainController')
3+
Author = 'Przemyslaw Klys'
4+
CmdletsToExport = @()
5+
CompanyName = 'Evotec'
6+
CompatiblePSEditions = @('Desktop', 'Core')
7+
Copyright = '(c) 2011 - 2026 Przemyslaw Klys @ Evotec. All rights reserved.'
8+
Description = 'Helper module for Active Directory with lots of useful functions that simplify supporting Active Directory.'
9+
FunctionsToExport = @('Add-ADACL', 'Compare-PingCastleReport', 'Compare-WinADGlobalCatalogObjects', 'Convert-ADSecurityDescriptor', 'Copy-ADOUSecurity', 'Disable-ADACLInheritance', 'Enable-ADACLInheritance', 'Export-ADACLObject', 'Find-WinADObjectDifference', 'Get-ADACL', 'Get-ADACLOwner', 'Get-DNSServerIP', 'Get-PingCastleReport', 'Get-WinADACLConfiguration', 'Get-WinADACLForest', 'Get-WinADBitlockerLapsSummary', 'Get-WinADBrokenProtectedFromDeletion', 'Get-WinADComputerACLLAPS', 'Get-WinADComputers', 'Get-WinADDelegatedAccounts', 'Get-WinADDFSHealth', 'Get-WinADDFSTopology', 'Get-WinADDHCP', 'Get-WinADDHCPHealthCheck', 'Get-WinADDHCPSummary', 'Get-WinADDiagnostics', 'Get-WinADDnsInformation', 'Get-WinADDnsIPAddresses', 'Get-WinADDnsRecords', 'Get-WinADDnsServerForwarder', 'Get-WinADDnsServerScavenging', 'Get-ADWinDnsServerZones', 'Get-WinADDNSZones', 'Get-WinADDomain', 'Get-WinADDomainControllerGenerationId', 'Get-WinADDomainControllerNetLogonSettings', 'Get-WinADDomainControllerNTDSSettings', 'Get-WinADDomainControllerOption', 'Get-WinADDuplicateObject', 'Get-WinADDuplicateSPN', 'Get-WinADForest', 'Get-WinADForestControllerInformation', 'Get-WinADForestOptionalFeatures', 'Get-WinADForestReplication', 'Get-WinADForestReplicationSummary', 'Get-WinADForestRoles', 'Get-WinADForestSchemaDetails', 'Get-WinADForestSchemaProperties', 'Get-WinADForestSites', 'Get-WinADForestSubnet', 'Get-WinADGroupMember', 'Get-WinADGroupMemberOf', 'Get-WinADGroups', 'Get-WinADKerberosAccount', 'Get-WinADLastBackup', 'Get-WinADLDAPBindingsSummary', 'Get-WinADLDAPSummary', 'Get-WinADLMSettings', 'Get-WinADObject', 'Get-WinADOrganization', 'Get-WinADPasswordPolicy', 'Get-WinADPrivilegedObjects', 'Get-WinADProtocol', 'Get-WinADProxyAddresses', 'Get-WinADServiceAccount', 'Get-WinADSharePermission', 'Get-WinADSIDHistory', 'Get-WinADSiteConnections', 'Get-WinADSiteCoverage', 'Get-WinADSiteLinks', 'Get-WinADSiteOptions', 'Get-WinADTombstoneLifetime', 'Get-WinADTrust', 'Get-WinADTrustLegacy', 'Get-WinADUserPrincipalName', 'Get-WinADUsers', 'Get-WinADUsersForeignSecurityPrincipalList', 'Get-WinADWellKnownFolders', 'Invoke-ADEssentials', 'Invoke-PingCastle', 'Invoke-WinADDHCPHealthCheck', 'New-ADACLObject', 'New-ADSite', 'Remove-ADACL', 'Remove-WinADDFSTopology', 'Remove-WinADDuplicateObject', 'Remove-WinADSharePermission', 'Rename-WinADUserPrincipalName', 'Repair-WinADACLConfigurationOwner', 'Repair-WinADBrokenProtectedFromDeletion', 'Repair-WinADEmailAddress', 'Repair-WinADForestControllerInformation', 'Request-ChangePasswordAtLogon', 'Request-DisableOnAccountExpiration', 'Restore-ADACLDefault', 'Set-ADACL', 'Set-ADACLInheritance', 'Set-ADACLOwner', 'Set-DnsServerIP', 'Set-WinADDiagnostics', 'Set-WinADDomainControllerNetLogonSettings', 'Set-WinADDomainControllerOption', 'Set-WinADForestACLOwner', 'Set-WinADReplication', 'Set-WinADReplicationConnections', 'Set-WinADShare', 'Set-WinADTombstoneLifetime', 'Show-WinADDHCPSummary', 'Show-WinADDNSRecords', 'Show-WinADForestReplicationSummary', 'Show-WinADGroupCritical', 'Show-WinADGroupMember', 'Show-WinADGroupMemberOf', 'Show-WinADKerberosAccount', 'Show-WinADLdapSummary', 'Show-WinADObjectDifference', 'Show-WinADOrganization', 'Show-WinADSIDHistory', 'Show-WinADSites', 'Show-WinADSitesCoverage', 'Show-WinADTrust', 'Show-WinADUserSecurity', 'Sync-WinADDomainController', 'Test-ADDomainController', 'Test-ADRolesAvailability', 'Test-ADSiteLinks', 'Test-DNSNameServers', 'Test-FSMORolesAvailability', 'Test-LDAP', 'Test-WinADDNSResolving', 'Test-WinADObjectReplicationStatus', 'Test-WinADVulnerableSchemaClass', 'Update-LastLogonTimestamp')
10+
GUID = '9fc9fd61-7f11-4f4b-a527-084086f1905f'
11+
ModuleVersion = '1.0.2'
12+
PowerShellVersion = '5.1'
13+
PrivateData = @{
14+
PSData = @{
15+
ProjectUri = 'https://github.com/EvotecIT/ADEssentials'
16+
RequireLicenseAcceptance = $false
17+
Tags = @('Windows', 'ActiveDirectory')
18+
ExternalModuleDependencies = @()
19+
}
20+
}
21+
RequiredModules = @(@{
22+
Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'
23+
ModuleName = 'PSSharedGoods'
24+
ModuleVersion = '0.0.313.1'
25+
}, @{
26+
Guid = 'a7bdf640-f5cb-4acf-9de0-365b322d245c'
27+
ModuleName = 'PSWriteHTML'
28+
ModuleVersion = '1.38.0'
29+
}, @{
30+
Guid = '5df72a79-cdf6-4add-b38d-bcacf26fb7bc'
31+
ModuleName = 'PSEventViewer'
32+
ModuleVersion = '1.0.22'
33+
})
34+
RootModule = 'ADEssentials.psm1'
35+
ScriptsToProcess = @()
3436
}

ADEssentials.psm1

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
#Get public and private function definition files.
2-
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue -Recurse )
3-
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue -Recurse )
4-
5-
$AssemblyFolders = Get-ChildItem -Path $PSScriptRoot\Lib -Directory -ErrorAction SilentlyContinue
6-
if ($AssemblyFolders.BaseName -contains 'Standard') {
7-
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Standard\*.dll -ErrorAction SilentlyContinue )
8-
} else {
9-
if ($PSEdition -eq 'Core') {
10-
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Core\*.dll -ErrorAction SilentlyContinue )
11-
} else {
12-
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Default\*.dll -ErrorAction SilentlyContinue )
13-
}
14-
}
15-
$FoundErrors = @(
16-
foreach ($Import in @($Assembly)) {
17-
try {
18-
Add-Type -Path $Import.Fullname -ErrorAction Stop
19-
} catch [System.Reflection.ReflectionTypeLoadException] {
20-
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
21-
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
22-
foreach ($E in $LoaderExceptions) {
23-
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
24-
}
25-
$true
26-
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
27-
} catch {
28-
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
29-
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
30-
foreach ($E in $LoaderExceptions) {
31-
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
32-
}
33-
$true
34-
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
35-
}
36-
}
37-
#Dot source the files
38-
foreach ($Import in @($Private + $Public)) {
39-
try {
40-
. $Import.Fullname
41-
} catch {
42-
Write-Error -Message "Failed to import functions from $($import.Fullname): $_"
43-
$true
44-
}
45-
}
46-
)
47-
48-
if ($FoundErrors.Count -gt 0) {
49-
$ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName
50-
Write-Warning "Importing module $ModuleName failed. Fix errors before continuing."
51-
break
52-
}
53-
1+
#Get public and private function definition files.
2+
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue -Recurse )
3+
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue -Recurse )
4+
5+
$AssemblyFolders = Get-ChildItem -Path $PSScriptRoot\Lib -Directory -ErrorAction SilentlyContinue
6+
if ($AssemblyFolders.BaseName -contains 'Standard') {
7+
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Standard\*.dll -ErrorAction SilentlyContinue )
8+
} else {
9+
if ($PSEdition -eq 'Core') {
10+
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Core\*.dll -ErrorAction SilentlyContinue )
11+
} else {
12+
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Default\*.dll -ErrorAction SilentlyContinue )
13+
}
14+
}
15+
$FoundErrors = @(
16+
foreach ($Import in @($Assembly)) {
17+
try {
18+
Add-Type -Path $Import.Fullname -ErrorAction Stop
19+
} catch [System.Reflection.ReflectionTypeLoadException] {
20+
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
21+
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
22+
foreach ($E in $LoaderExceptions) {
23+
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
24+
}
25+
$true
26+
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
27+
} catch {
28+
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
29+
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
30+
foreach ($E in $LoaderExceptions) {
31+
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
32+
}
33+
$true
34+
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
35+
}
36+
}
37+
#Dot source the files
38+
foreach ($Import in @($Private + $Public)) {
39+
try {
40+
. $Import.Fullname
41+
} catch {
42+
Write-Error -Message "Failed to import functions from $($import.Fullname): $_"
43+
$true
44+
}
45+
}
46+
)
47+
48+
if ($FoundErrors.Count -gt 0) {
49+
$ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName
50+
Write-Warning "Importing module $ModuleName failed. Fix errors before continuing."
51+
break
52+
}
53+
5454
Export-ModuleMember -Function '*' -Alias '*'

0 commit comments

Comments
 (0)