protected override void ProcessRecord()
        {
            if (ListProfile.IsPresent)
            {
                WriteWarning("The ListProfile switch is deprecated and will be removed from a future release.  Please use ListProfileDetail instead.");
                WriteObject(SettingsStore.GetProfileInfo(ProfileLocation).Select(pi => pi.ProfileName), true);
                return;
            }
            else if (ListProfileDetail.IsPresent)
            {
                WriteObject(SettingsStore.GetProfileInfo(ProfileLocation), true);
                return;
            }

            if (string.IsNullOrEmpty(ProfileName))
            {
                var creds = this.SessionState.PSVariable.Get(SessionKeys.AWSCredentialsVariableName);
                if (creds != null && creds.Value != null && creds.Value is AWSPSCredentials)
                {
                    WriteObject((creds.Value as AWSPSCredentials).Credentials);
                }
            }
            else
            {
                CredentialProfile profile;
                if (SettingsStore.TryGetProfile(ProfileName, ProfileLocation, out profile))
                {
                    WriteObject(profile.GetAWSCredentials(profile.CredentialProfileStore));
                }
            }
        }
        private static bool TryLoad(string name, string profileLocation, ref RegionEndpoint region, ref RegionSource source)
        {
            CredentialProfile profile;

            if (SettingsStore.TryGetProfile(name, profileLocation, out profile) && profile.Region != null)
            {
                region = profile.Region;
                source = RegionSource.Saved;
                return(true);
            }
            return(false);
        }
        private void GetFromDefaultProfile(out AWSPSCredentials awsPSCredentialsFromDefaultProfile, out RegionEndpoint regionFromDefaultProfile)
        {
            CredentialProfile profile;

            if (SettingsStore.TryGetProfile(SettingsStore.PSDefaultSettingName, ProfileLocation, out profile))
            {
                AWSCredentials defaultAWSCredentials;
                if (SettingsStore.TryGetAWSCredentials(SettingsStore.PSDefaultSettingName, ProfileLocation, out defaultAWSCredentials))
                {
                    awsPSCredentialsFromDefaultProfile = new AWSPSCredentials(defaultAWSCredentials, SettingsStore.PSDefaultSettingName, CredentialsSource.Profile);
                }
                else
                {
                    awsPSCredentialsFromDefaultProfile = null;
                }

                regionFromDefaultProfile = profile.Region;
            }
            else
            {
                awsPSCredentialsFromDefaultProfile = null;
                regionFromDefaultProfile           = null;
            }
        }