/// <summary>
        /// The ProcessRecord method returns a Prefetch object for the File specified
        /// by the Path property, or iterates through all .pf files in the
        /// C:\Windows\Prefetch directory to output an array of Prefetch objects.
        /// </summary>
        protected override void ProcessRecord()
        {
            switch (ParameterSetName)
            {
            case "ByVolume":
                if (fast)
                {
                    WriteObject(Prefetch.GetInstances(volume, fast));
                }
                else
                {
                    WriteObject(Prefetch.GetInstances(volume));
                }
                break;

            case "ByPath":
                if (fast)
                {
                    // Output the Prefetch object for the corresponding file
                    WriteObject(Prefetch.Get(filePath, fast));
                }
                else
                {
                    // Output the Prefetch object for the corresponding file
                    WriteObject(Prefetch.Get(filePath));
                }
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// The ProcessRecord method returns a Prefetch object for the File specified
        /// by the Path property, or iterates through all .pf files in the
        /// C:\Windows\Prefetch directory to output an array of Prefetch objects.
        /// </summary>
        protected override void ProcessRecord()
        {
            // Get current volume
            string volLetter = Directory.GetCurrentDirectory().Split('\\')[0];
            string volume    = @"\\.\" + volLetter;

            // Get a handle to the volume
            IntPtr hVolume = NativeMethods.getHandle(volume);

            // Create a FileStream to read from the volume handle
            FileStream streamToRead = NativeMethods.getFileStream(hVolume);

            // Get a byte array representing the Master File Table
            byte[] MFT = MasterFileTable.GetBytes(hVolume, streamToRead);

            // If the FilePath parameter is used
            if (this.MyInvocation.BoundParameters.ContainsKey("Path"))
            {
                //Test that FilePath exists
                if (File.Exists(filePath))
                {
                    // Output the Prefetch object for the corresponding file
                    WriteObject(Prefetch.Get(volume, streamToRead, MFT, filePath));
                }

                // If file doesnt exist, throw error
                else
                {
                    throw new FileNotFoundException((filePath + " does not exist.  Please enter a valid file path."));
                }
            }

            // If no FilePath is provided, return all Prefetch files
            else
            {
                // Build Prefetch directory path
                string prefetchPath = volLetter + @"\\Windows\\Prefetch";

                // Get list of file in the Prefetch directory that end in the .pf extension
                var pfFiles = System.IO.Directory.GetFiles(prefetchPath, "*.pf");

                // Iterate through Prefetch Files
                foreach (var file in pfFiles)
                {
                    // Output the Prefetch object for the corresponding file
                    WriteObject(Prefetch.Get(volume, streamToRead, MFT, file));
                }
            }
        } // ProcessRecord
Пример #3
0
        protected override void ProcessRecord()
        {
            // If the FilePath parameter is used
            if (this.MyInvocation.BoundParameters.ContainsKey("Path"))
            {
                //Test that FilePath exists
                if (File.Exists(filePath))
                {
                    if (fast)
                    {
                        // Output the Prefetch object for the corresponding file
                        WriteObject(Prefetch.Get(filePath, fast));
                    }
                    else
                    {
                        // Output the Prefetch object for the corresponding file
                        WriteObject(Prefetch.Get(filePath));
                    }
                }

                // If file doesnt exist, throw error
                else
                {
                    throw new FileNotFoundException((filePath + " does not exist.  Please enter a valid file path."));
                }
            }

            // If no FilePath is provided, return all Prefetch files
            else
            {
                if (fast)
                {
                    WriteObject(Prefetch.GetInstances(volume, fast));
                }
                else
                {
                    WriteObject(Prefetch.GetInstances(volume));
                }
            }
        } // ProcessRecord