31 lines
965 B
PowerShell
31 lines
965 B
PowerShell
|
function Set-LocalCachedAWSProfile {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Used to store or change the locally cached AWS profile from the environment store
|
||
|
|
||
|
.PARAMETER ProfileName
|
||
|
The name of an AWS profile
|
||
|
|
||
|
.PARAMETER NoValidate
|
||
|
Don't check the local profile configuration to make sure the profile exists
|
||
|
#>
|
||
|
[CmdletBinding()]
|
||
|
[OutputType([void])]
|
||
|
param (
|
||
|
[Parameter(Mandatory = $true, Position = 0)]
|
||
|
[string]$ProfileName,
|
||
|
[switch]$NoValidate
|
||
|
)
|
||
|
|
||
|
$logLead = (Get-LogLeadName)
|
||
|
|
||
|
if (!$NoValidate) {
|
||
|
$credentials = (Get-LocalConfiguredAWSProfileNames)
|
||
|
if (!$credentials.Contains($ProfileName)) {
|
||
|
throw "$logLead : Can not find the value [$ProfileName] in your local credentials file. Valid values are [$($credentials -join ',')]"
|
||
|
}
|
||
|
Assert-ValidAWSProfileName -ProfileName $ProfileName
|
||
|
}
|
||
|
|
||
|
Set-EnvironmentVariable -Name "USERCACHE_AWSProfileKey" -Value $ProfileName -StoreName User
|
||
|
}
|