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
-ProfileLocation <String>

StoredProfile

Initialize-AWSDefaultConfiguration
-ProfileName <String>
-ProfileLocation <String>
-Region <Object>
-NetworkCredential <PSCredential>

BasicOrSession

Initialize-AWSDefaultConfiguration
-ProfileLocation <String>
-Region <Object>
-AccessKey <String>
-SecretKey <String>
-SessionToken <String>

AssumeRole

Initialize-AWSDefaultConfiguration
-ProfileLocation <String>
-Region <Object>
-ExternalID <String>
-MfaSerial <String>
-RoleArn <String>
-SourceProfile <String>

AWSCredentialsObject

Initialize-AWSDefaultConfiguration
-ProfileLocation <String>
-Region <Object>
-Credential <AWSCredentials>

RegionOnly

Initialize-AWSDefaultConfiguration
-ProfileLocation <String>
-Region <Object>

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

-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?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required?True
Position?Named
Accept pipeline input?True (ByValue, )
-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)
-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>
Amazon.PowerShell.Common.InitializeDefaultConfigurationCmdlet+InitializeDefaultConfigurationCmdletParameters.ProfileLocation
Required?False
Position?202
Accept pipeline input?True (ByPropertyName)
-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?True
Position?201
Accept pipeline input?True (ByPropertyName)
-Region <Object>
Amazon.PowerShell.Common.InitializeDefaultConfigurationCmdlet+InitializeDefaultConfigurationCmdletParameters.Region
Required?True
Position?211
Accept pipeline input?True (ByPropertyName)
-RoleArn <String>
The ARN of the role to assume for assume role credentials.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-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?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-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)
-SourceProfile <String>
The name of the source profile to be used by assume role credentials.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)

Inputs

You can pipe a AWSCredentials object to this cmdlet for the Credential parameter.

Outputs

None
This cmdlet does not generate any output.

Examples

Example 1

PS C:\>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

PS C:\>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

PS C:\>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

PS C:\>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 thenm active.

Supported Version

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