This repository has been archived by the owner on Aug 15, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
PSWriteExcel.psm1
35 lines (32 loc) · 1.58 KB
/
PSWriteExcel.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
28
29
30
31
32
33
34
35
#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 )
if ($PSEdition -eq 'Core') {
# $Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Core\Microsoft.Extensions.*.dll -ErrorAction SilentlyContinue )
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Core\*.dll -ErrorAction SilentlyContinue )
} else {
#$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Default\System.Text*.dll -ErrorAction SilentlyContinue )
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Default\*.dll -ErrorAction SilentlyContinue )
}
Foreach ($Import in @($Assembly)) {
try {
Add-Type -Path $Import.Fullname -ErrorAction Stop
} catch [System.Reflection.ReflectionTypeLoadException] {
Write-Error -Message "Message: $($_.Exception.Message)"
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
#Write-Error -Message "LoaderExceptions: $($_.Exception.LoaderExceptions)"
} catch {
Write-Error -Message "Message: $($_.Exception.Message)"
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
#Write-Error -Message "LoaderExceptions: $($_.Exception.LoaderExceptions)"
}
}
#Dot source the files
Foreach ($Import in @($Public + $Private)) {
Try {
. $Import.Fullname
} Catch {
Write-Error -Message "Failed to import function $($import.Fullname): $_"
}
}
Export-ModuleMember -Function '*' -Alias '*'