Private/Import-AWSSDK.ps1

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
function Import-AWSSDK {
    [cmdletbinding()]
    Param()
    if (!([AppDomain]::CurrentDomain.GetAssemblies() | Where-Object {$_.Location -like "*AWSSDK.CloudFormation.dll"})) {
        if ($IsCoreCLR) {
            Write-Verbose "Loading AWS SDK for *NetCore*!"
            $sdkPath = (Join-Path $Script:VaporshellPath "bin\NetCore" -Resolve)
        }
        else {
            Write-Verbose "Loading AWS SDK for *Net45*!"
            $sdkPath = (Join-Path $Script:VaporshellPath "bin\Net45" -Resolve)
        }
        Get-ChildItem $sdkPath -Filter "*.dll" | ForEach-Object {
            [reflection.assembly]::LoadFrom("$($_.FullName)") | Out-Null
        }
    }
    else {
        if ($IsCoreCLR) {
            Write-Verbose "AWS SDK for *NetCore* is already loaded, continuing module import"
        }
        else {
            Write-Verbose "AWS SDK for *Net45* is already loaded, continuing module import"
        }
    }
}