Skip to content

Instantly share code, notes, and snippets.

@Echooff3
Created August 9, 2023 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Echooff3/737bb402cd5419b743d186efebc5c5bd to your computer and use it in GitHub Desktop.
Save Echooff3/737bb402cd5419b743d186efebc5c5bd to your computer and use it in GitHub Desktop.
Update AWS Creds from Powershell
# Make sure you have a creds object in your clipboard
function creds () {
Import-Module "Microsoft.PowerShell.Management"
Import-Module "PsIni" # Make sure you have this installed
$pth = "~\.aws\credentials" # Update to your path
$creds = Get-IniContent $pth
$cb = Get-Clipboard
try {
$first, $rest = $cb
$section = "default"
$final = @($section, $rest[0], $rest[1], $rest[2])
$final2 = @($rest[0], $rest[1], $rest[2])
$creds[$section]["aws_access_key_id"] = $rest[0]
$creds[$section]["aws_secret_access_key"] = $rest[1]
$creds[$section]["aws_session_token"] = $rest[2]
Out-IniFile -FilePath $pth -InputObject $creds -Force
}
catch { "Check your clipboard" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment