From 2c8181c898b15f26340fab6703df44baa10eab7a Mon Sep 17 00:00:00 2001 From: Pelle Johnsen Date: Wed, 17 Apr 2024 16:12:59 +0200 Subject: [PATCH] docs: add info on using with powershell --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 9a5f14c..d92bbb4 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,26 @@ aws-sso-cli() { } ``` +For windows you can add this to your PowerShell profile (use e.g. `notepad $PROFILE`): +```powershell +function Set-AWSSSOEnvironmentVariables { + [CmdletBinding()] + param() + + $commandOutput = Invoke-Expression -Command 'npx aws-sso-cli' + foreach ($line in $commandOutput) { + if ($line -match 'export\s+(\w+)=(\S+)') { + $name = $matches[1] + $value = $matches[2] + Write-Host "Setting environment variable $name" + Set-Item -Path "env:$name" -Value $value + } + } +} + +Set-Alias -Name aws-sso-cli -Value Set-AWSSSOEnvironmentVariables +``` + ## Usage ```