EWS.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
param (
    [ValidateSet(
        'useScriptBlock',
        'useScript'
    )]
    [String]$DotSourceMethod = 'useScriptBlock'
)

foreach ($file in Get-ChildItem -Path $PSScriptRoot\*.ps1) {
    if ($DotSourceMethod -eq 'useScriptBlock') {
        # Avoiding bug in WMF5/Install-Module
        # See: https://constantinekokkinos.com/articles/64/troubleshooting-powershell-and-net-when-error-messages-are-not-enough
        $ExecutionContext.InvokeCommand.InvokeScript(
            $false, 
            (
                [scriptblock]::Create(
                    [io.file]::ReadAllText(
                        $file.FullName,
                        [Text.Encoding]::UTF8
                    )
                )
            ), 
            $null, 
            $null
        )
    } else {
        . $file.FullName
    }
}

$connections = @{}