AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Creates or updates the credential profile named 'default' using supplied keys, existing credentials or profile, or EC2 metadata. The profile and a default region is then set active in the current shell.

Syntax

InstanceProfile (Default)

Initialize-AWSDefaultConfiguration
-Scope <VariableScope>

StoredProfile

Initialize-AWSDefaultConfiguration
-Scope <VariableScope>

BasicOrSession

Initialize-AWSDefaultConfiguration
-Scope <VariableScope>

AssumeRole

Initialize-AWSDefaultConfiguration
-Scope <VariableScope>
-ExternalID <String>
-MfaSerial <String>
-RoleArn <String>
-SourceProfile <String>

AWSCredentialsObject

Initialize-AWSDefaultConfiguration
-Scope <VariableScope>

RegionOnly

Initialize-AWSDefaultConfiguration
-Scope <VariableScope>

Description

Creates or updates the credential profile named 'default' and sets the profile, and optionally a region, as active in the current shell. The credential data to be stored in the 'default' profile can be provided from:
  • Supplied access and secret key parameters for AWS credentials
  • A pre-existing profile
  • A credentials object
  • Active credentials in the current shell (in the variable $StoredAWSCredentials)
  • EC2 role metadata (for instances launched with instance profiles)
A default region to assume when the default profile is active is also set using the -Region parameter, from a default region already set in the current shell or, if the cmdlet is executing on an EC2 instance, from the instance metadata. If a region setting cannot be determined from a parameter or the shell you are prompted to select one. Note that if run on an EC2 instance and you want to select a region other than the region containing the instance you should supply the -Region parameter so that the cmdlet does not inspect EC2 instance metadata to auto-discover the region. In all cases a profile named 'default' will be created or updated to contain the specified credential and region data. Note that if the credential source is another profile this cmdlet effectively copies the credential data from the source profile to the 'default' profile. When the cmdlet exits the active credentials can be accessed in the shell via a variable named $StoredAWSCredentials. The active region can be found in the variable $StoredAWSRegion. Note: For scripts written against earlier versions of this module this cmdlet can also be invoked with the alias Initialize-AWSDefaults.

Note: For scripts written against earlier versions of this module this cmdlet can also be invoked with the alias, Initialize-AWSDefaults.

Parameters

-ExternalID <String>
The user-defined external ID to be used when assuming a role, if required by the role.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-MfaSerial <String>
The MFA serial number to be used when assuming a role, if required by the role.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-RoleArn <String>
The ARN of the role to assume for assume role credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-Scope <VariableScope>
This parameter allows to specify the scope of the shell variables set by this cmdlet. For details about variables scopes see https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-SourceProfile <String>
The name of the source profile to be used by assume role credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)

Common Credential and Region Parameters

-AccessKey <String>
The AWS access key for the user account. This can be a temporary access key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAK
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-NetworkCredential <PSCredential>
Used with SAML-based authentication when ProfileName references a SAML role profile. Contains the network credentials to be supplied during authentication with the configured identity provider's endpoint. This parameter is not required if the user's default network identity can or should be used during authentication.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ProfileLocation <String>
Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials.If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.
Required?False
Position?202
Accept pipeline input?True (ByPropertyName)
AliasesAWSProfilesLocation, ProfilesLocation
-ProfileLocation <String>
Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials.If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.
Required?False
Position?202
Accept pipeline input?True (ByPropertyName)
AliasesAWSProfilesLocation, ProfilesLocation
-ProfileName <String>
The user-defined name of an AWS credentials or SAML-based role profile containing credential information. The profile is expected to be found in the secure credential file shared with the AWS SDK for .NET and AWS Toolkit for Visual Studio. You can also specify the name of a profile stored in the .ini-format credential file used with the AWS CLI and other AWS SDKs.
Required?False
Position?201
Accept pipeline input?True (ByPropertyName)
AliasesStoredCredentials, AWSProfileName
-Region <Object>
The system name of an AWS region or an AWSRegion instance. This governs the endpoint that will be used when calling service operations. Note that the AWS resources referenced in a call are usually region-specific.
Required?False
Position?211
Accept pipeline input?True (ByPropertyName)
AliasesRegionToCall
-SecretKey <String>
The AWS secret key for the user account. This can be a temporary secret key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSK, SecretAccessKey
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesST

Outputs

None
This cmdlet does not generate any output.

Examples

Example 1

Initialize-AWSDefaultConfiguration
Tests to see if a profile named 'default' exists. If it does the credential and region data in the profile are loaded and set as active in the current shell.

If a 'default' profile does not exist and the cmdlet is running on the local workstation the user is prompted to enter the AWS access and secret keys for an account, and to select a default region. If run on an Amazon EC2 instance the instance metadata is inspected to determine if the instance was launched with a role and if so credentials are obtained from the role before prompting for a default region. The credentials and region selection are then saved into a profile named 'default' and set as active in the current shell.

Example 2

Initialize-AWSDefaultConfiguration -AccessKey AKIAIOSFODNN7EXAMPLE -SecretKey wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY -Region us-west-2
Saves the specified credential keys and default region selection to a profile named 'default'. On exit the credentials and region are set as active in the current shell.

Example 3

Initialize-AWSDefaultConfiguration -ProfileName myProfile -Region us-west-2
Loads the credential data from the profile named 'myProfile' and saves it to a profile named 'default' (effectively copying credential data from one profile to another). The default profile is also updated to assume a default region of 'us-west-2'. When the cmdlet exists the specified credentials and region are set active in the current shell.

Example 4

Initialize-AWSDefaultConfiguration -Region us-west-2
If a profile named 'default' exists it is updated to assume a default region of 'us-west-2'. If the profile does not exist and the cmdlet is running on the local workstation the user is prompted to enter the AWS access and secret keys for an account. If run on an Amazon EC2 instance the instance metadata is inspected to determine if the instance was launched with a role and if so credentials are obtained from the role. A profile named 'default' is then created containing the discovered or entered credentials and region, and the current shell updated to set them active.

Supported Version

AWS Tools for PowerShell: 2.x.y.z