snicol.psm1
<#
=========================================================================== Organization: Spencer Nicol Filename: snicol.psm1 ------------------------------------------------------------------------- Module Name: snicol =========================================================================== #> #Import dependent modules into session $modules = @( Get-ChildItem -Path $PSScriptRoot\Utilities\* -Include *.psd1 -Recurse -ErrorAction SilentlyContinue ) if ($modules) { Import-Module $modules -Force -Global } #Get public and private function definition files. $public = @( Get-ChildItem -Path $PSScriptRoot\Functions\Public\*.ps1 -ErrorAction SilentlyContinue ) $private = @( Get-ChildItem -Path $PSScriptRoot\Functions\Private\*.ps1 -ErrorAction SilentlyContinue ) #Dot source the files Foreach ($import in @($public + $private)) { Try { . $import.fullname } Catch { Write-Error -Message "Failed to import function $($import.fullname): $_" } } $publicFunctions = [Management.Automation.Language.Parser]::ParseInput((Get-Content $public -Raw), [ref]$null, [ref]$null).EndBlock.Statements.FindAll([Func[Management.Automation.Language.Ast, bool]] { $args[0] -is [Management.Automation.Language.FunctionDefinitionAst] }, $false) | Select-Object -ExpandProperty Name Export-ModuleMember -Function $publicFunctions |