SqlPipeline.psm1
#----------------------------------------------- # NOTES #----------------------------------------------- <# Inspired by Tutorial of RamblingCookieMonster in http://ramblingcookiemonster.github.io/Building-A-PowerShell-Module/ and https://github.com/RamblingCookieMonster/PSStackExchange/blob/db1277453374cb16684b35cf93a8f5c97288c41f/PSStackExchange/PSStackExchange.psm1 #> #----------------------------------------------- # ENUMS #----------------------------------------------- #----------------------------------------------- # ADD MODULE PATH, IF NOT PRESENT #----------------------------------------------- Import-Module ImportDependency #----------------------------------------------- # LOAD PUBLIC AND PRIVATE FUNCTIONS #----------------------------------------------- $Public = @( Get-ChildItem -Path "$( $PSScriptRoot )/public/*.ps1" -Recurse -ErrorAction SilentlyContinue ) $Private = @( Get-ChildItem -Path "$( $PSScriptRoot )/private/*.ps1" -Recurse -ErrorAction SilentlyContinue ) # dot source the files @( $Public + $Private ) | ForEach-Object { $import = $_ Write-Verbose "Load $( $import.fullname )" Try { . $import.fullname } Catch { Write-Error -Message "Failed to import function $( $import.fullname ): $( $_ )" } } #----------------------------------------------- # SET SOME VARIABLES ONLY VISIBLE TO MODULE AND FUNCTIONS #----------------------------------------------- # Define the variables New-Variable -Name timestamp -Value $null -Scope Script -Force # Start time of this module New-Variable -Name logDivider -Value $null -Scope Script -Force # String of dashes to use in logs New-Variable -Name moduleRoot -Value $null -Scope Script -Force # Current location root of this module # Set the variables now $Script:timestamp = [datetime]::Now $Script:moduleRoot = $PSScriptRoot.ToString() #----------------------------------------------- # IMPORT DEPENDENCIES #----------------------------------------------- # Load dependencies . ( Join-Path -Path $PSScriptRoot.ToString() -ChildPath "/bin/dependencies.ps1" ) # Load modules If ( $psModules.Count -gt 0 ) { Import-Dependency -Module $psModules } # TODO For future you need in linux maybe this module for outgrid-view, which is also supported on console only: microsoft.powershell.consoleguitools # Load packages from current local libfolder $pse = Get-PSEnvironment If ( $psLocalPackages.Count -gt 0 -and $pse.InstalledLocalPackages.Count -gt 0 ) { Import-Dependency -LoadWholePackageFolder } # Load assemblies $psAssemblies | ForEach-Object { $ass = $_ Add-Type -AssemblyName $ass } #----------------------------------------------- # READ IN CONFIG FILES AND VARIABLES #----------------------------------------------- Export-ModuleMember -Function $Public.Basename |