Query services on AWS accounts:
Get-S3Bucket -ProfileName yourAWSaccountName = get S3 buckets for AWS account
Install and configure PowerShell AWS tools:
PS C:\>$Profile = find your current session Profile file path
Add the following lines to your profile PS1 file:
#Change the InstallationPolicy value of the PS repository before beginning the modules installation
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Import-Module AWSPowerShell.NetCore
Install-Module -Name ImportExcel -Scope CurrentUser -Force #install module "ImportExcel"
# Install-Module -Name AWS.Tools.Installer
# Install-AWSToolsModule AWS.Tools.Common
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
# Get-Module -ListAvailable
Get-AWSPowerShellVersion
Write-Host "PowerShell version:"
$PSVersionTable.PSVersion.ToString() #print PS version on the screen
Get-AWSCredentials -ListProfileDetail
================================================================================
Other commands you can run on your terminal:
Install-Module -name AWSPowerShell.NetCore -Scope CurrentUser = install AWS tools for PowerShell for logged in user
Set-ExecutionPolicy RemoteSigned
Get-AWSCredentials -ListProfileDetail = get on-screen list all configured profiles
Update-AWSToolsModule -CleanUp
Uninstall-Module -Name AWSPowerShell.NetCore -AllVersions
Configure your AWS local Profile with AccessKey and SecretKey
aws configure = configure AWS profile on your local machine
Set-AWSCredentials -AccessKey {xx} -SecretKey {xx} -StoreAs {yourAWSProfile} = another way to configure AWS profile
Set-AWSCredential -StoreAs yourRoleName -SourceProfile yourAWSProfile -RoleArn yourARNforRole = assume role of member AWS account Remove-AWSCredentialProfile -ProfileName MyAWS -Confirm:$false = delete AWS profile
https://4sysops.com/archives/working-with-aws-credentials-using-powershell/
setx AWS_PROFILE yourAWSProfile
aws sts get-session-token
Initialize-AWSDefaults -ProfileName yourAWSProfile -Region us-east-2 = initialize "yourAWSProfile" profile for that PowerShell session
Configure AWS SSO and login/logout from your session
Get-AWSCredential -ListProfileDetail
aws configure list
aws configure sso = configure your sso for the Dev or Prod AWS Organization, and then run one of the below commands:
aws sso login --profile YourDevProfile = login to YourDevProfile configured on .aws\config file
aws sso login --profile YourProdProfile = login to YourProdProfile configured on .aws\config file
aws s3 ls --profile YourProdProfile = list all S3 buckets in that AWS account/profile
aws s3api list-buckets --output json | jq .Buckets[].Name
Edit env var
$env:AWS_PROFILE="yourAWSuserName"