ecc-tool.psm1
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 |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 #region LoadFunctions $PublicFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Public/*.ps1" -Recurse -Exclude *.Tests.ps1 -ErrorAction SilentlyContinue ) $PrivateFunctions = @( Get-ChildItem -Path "$PSScriptRoot/Private/*.ps1" -Recurse -Exclude *.Tests.ps1 -ErrorAction SilentlyContinue ) # Dot source the functions foreach ($file in @($PublicFunctions + $PrivateFunctions)) { try { . $file.FullName } catch { $exception = ([System.ArgumentException]"Function not found") $errorId = "Load.Function" $errorCategory = 'ObjectNotFound' $errorTarget = $file $errorItem = New-Object -TypeName System.Management.Automation.ErrorRecord $exception, $errorId, $errorCategory, $errorTarget $errorItem.ErrorDetails = "Failed to import function $($file.BaseName)" throw $errorItem } } Export-ModuleMember -Function $PublicFunctions.BaseName -Alias * $InformationPreference = "continue" #endregion LoadFunctions |