/// <summary>
        ///     Executes the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            MediaServicesClient = MediaServicesClient ?? new MediaServicesClient(CurrentContext.Subscription, WriteDebug);

            if (!string.IsNullOrEmpty(Name))
            {
                MediaServiceAccountDetails account = null;
                CatchAggregatedExceptionFlattenAndRethrow(() => { account = new MediaServiceAccountDetails(MediaServicesClient.GetMediaServiceAsync(Name).Result); });
                WriteObject(account, false);
            }
            else
            {
                var accounts = new List<MediaServiceAccount>();
                accounts.AddRange(MediaServicesClient.GetMediaServiceAccountsAsync().Result.Accounts.Select(c=>new MediaServiceAccount(c)));
                // Output results
                WriteMediaAccounts(accounts);
            }
        }
        public override void ExecuteCmdlet()
        {
            ConfirmAction(Force.IsPresent,
                          string.Format(Resources.RegenerateKeyWarning),
                          Resources.RegenerateKeyWhatIfMessage,
                          string.Empty,
                          () =>
                          {
                              MediaServicesClient = MediaServicesClient ?? new MediaServicesClient(Profile, Profile.Context.Subscription, WriteDebug);

                              
                              AzureOperationResponse result = null;
                              CatchAggregatedExceptionFlattenAndRethrow(() => { result = MediaServicesClient.RegenerateMediaServicesAccountAsync(Name, KeyType).Result; });
                            
                              MediaServiceAccountDetails account = null;
                              CatchAggregatedExceptionFlattenAndRethrow(() => { account = new MediaServiceAccountDetails(MediaServicesClient.GetMediaServiceAsync(Name).Result); });
                              string newKey = KeyType == MediaServicesKeyType.Primary ? account.AccountKeys.Primary : account.AccountKeys.Secondary;

                              WriteObject(newKey);
                          });
        }