ps/Modules/Alkami.PowerShell.Common/Public/Import-AWSModule.ps1

24 lines
736 B
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Import-AWSModule {
<#
.SYNOPSIS
Load the AWS module in a common way, only load it if it hasn't been loaded yet
#>
[CmdletBinding()]
param (
)
if ($null -eq (Get-Module AWSPowershell)) {
try {
(Import-Module AWSPowershell -Scope Global) | Out-Null
} catch {
$modulePath = "C:\Program Files (x86)\AWS Tools\PowerShell\awspowershell"
if (!(Test-Path $modulePath)) {
Write-Error "Could not find the path for the AWSPowershell module, expected to find it at [$modulePath]"
} else {
Write-Error "Could not import AWSPowershell module"
Write-Error $_.Exception.Message
}
}
}
}