private bool ValidateOrRemoveAutoMountedDrive(PSDriveInfo drive, SessionStateScope scope)
 {
     bool flag = true;
     try
     {
         DriveInfo info = new DriveInfo(drive.Name);
         flag = info.DriveType != DriveType.NoRootDirectory;
     }
     catch (LoopFlowException)
     {
         throw;
     }
     catch (PipelineStoppedException)
     {
         throw;
     }
     catch (ActionPreferenceStopException)
     {
         throw;
     }
     catch (Exception exception)
     {
         CommandProcessorBase.CheckForSevereException(exception);
         flag = false;
     }
     if (!flag)
     {
         DriveCmdletProvider driveProviderInstance = null;
         try
         {
             driveProviderInstance = this.GetDriveProviderInstance(this.ExecutionContext.ProviderNames.FileSystem);
         }
         catch (NotSupportedException)
         {
         }
         catch (ProviderNotFoundException)
         {
         }
         if (driveProviderInstance == null)
         {
             return flag;
         }
         CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);
         try
         {
             driveProviderInstance.RemoveDrive(drive, context);
         }
         catch (Exception exception2)
         {
             CommandProcessorBase.CheckForSevereException(exception2);
         }
         scope.RemoveDrive(drive);
     }
     return flag;
 }
        /// <summary>
        /// Determines if the specified automounted drive still exists. If not,
        /// the drive is removed.
        /// </summary>
        /// 
        /// <param name="drive">
        /// The drive to validate or remove.
        /// </param>
        /// 
        /// <param name="scope">
        /// The scope the drive is in.  This will be used to remove the drive
        /// if necessary.
        /// </param>
        /// 
        /// <returns>
        /// True if the drive is still valid, false if the drive was removed.
        /// </returns>
        /// 
        private bool ValidateOrRemoveAutoMountedDrive(PSDriveInfo drive, SessionStateScope scope)
        {
            bool result = true;
            try
            {
                System.IO.DriveInfo systemDriveInfo = new System.IO.DriveInfo(drive.Name);
                result = systemDriveInfo.DriveType != DriveType.NoRootDirectory;
            }
            catch (LoopFlowException)
            {
                throw;
            }
            catch (PipelineStoppedException)
            {
                throw;
            }
            catch (ActionPreferenceStopException)
            {
                throw;
            }
            catch (Exception e)
            {
                CommandProcessorBase.CheckForSevereException(e);
                // Assume any exception means the drive is no longer valid and needs
                // to be removed.

                result = false;
            }

            if (!result)
            {
                DriveCmdletProvider driveProvider = null;

                try
                {
                    driveProvider =
                        GetDriveProviderInstance(this.ExecutionContext.ProviderNames.FileSystem);
                }
                catch (NotSupportedException)
                {
                }
                catch (ProviderNotFoundException)
                {
                }

                if (driveProvider != null)
                {
                    CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);

                    try
                    {
                        // Give the provider a chance to cleanup
                        driveProvider.RemoveDrive(drive, context);
                    }
                    // Ignore any exceptions the provider throws because we
                    // are doing this without an explicit request from the
                    // user. Since the provider can throw any exception
                    // we must catch all exceptions here.
                    catch (Exception e)
                    {
                        CommandProcessorBase.CheckForSevereException(e);
                    }


                    scope.RemoveDrive(drive);
                }
            }

            return result;
        } // ValidateOrRemoveAutoMountedDrive