/// <summary>
        /// Get the default profile for the current cmdlet invocation
        /// </summary>
        /// <returns>The default profile, whether it is a process-specific profile, ot a profile for the current user</returns>
        protected virtual IProfileOperations GetDefaultProfile()
        {
            IProfileOperations result = null;
            var currentProfile        = DefaultProfile as AzureRmProfile;

            switch (GetContextModificationScope())
            {
            case ContextModificationScope.Process:
                result = currentProfile;
                break;

            case ContextModificationScope.CurrentUser:
                result = new AzureRmAutosaveProfile(currentProfile, ProtectedFileProvider.CreateFileProvider(Path.Combine(AzureSession.Instance.ARMProfileDirectory, AzureSession.Instance.ARMProfileFile), FileProtection.ExclusiveWrite));
                break;
            }

            return(result);
        }
        void EnsureProtectedCache(IProfileOperations profile, byte[] cacheData)
        {
            if (profile == null || cacheData == null)
            {
                return;
            }

            AzureRmAutosaveProfile autosave = profile as AzureRmAutosaveProfile;
            var protectedcache = AzureSession.Instance.TokenCache as ProtectedFileTokenCache;

            if (autosave != null && protectedcache == null && cacheData.Any())
            {
                try
                {
                    var cache = new ProtectedFileTokenCache(cacheData, AzureSession.Instance.DataStore);
                }
                catch
                {
                    WriteWarning(Resources.ImportAuthenticationFailure);
                }
            }
        }