PowerShell – How to Find and Open Previous Versions of a Folder

powershellprevious versionswindowswindows 8windows-explorer

I am running Windows 8 Enterprise x64. When I open \\localhost\c$ as a network folder, and then using a context menu open the Properties window of a subfolder (e.g. \\localhost\c$\Deploy as in the example below), there is the Previous Versions tab where I can see a list of available previous versions of the folder, along with corresponding timestamps:

Previous Versions Tab


If I select a version and click the Open button, a new Explorer window is opened where I can browse the selected previous version of the folder:

Location on General Tab


The address bar displays a location where a timestamp (in a long human-readable form) is appended to each folder name. This location, if copied from there, cannot be directly used as a valid path in another Explorer window or a command line tool. But if I open the Properties window of a subfloder, then it displays a location of the subfolder in a form like \\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy. This form can actually be used both in the Explorer and the command line:

C:\>dir \\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy /s
 Volume in drive \\localhost\c$ is OSDisk
 Volume Serial Number is ����-����

 Directory of \\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy

04/11/2013  10:53 AM    <DIR>          .
04/11/2013  10:53 AM    <DIR>          ..
04/11/2013  10:53 AM    <DIR>          Tools
               0 File(s)              0 bytes

 Directory of \\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy\Tools

04/11/2013  10:53 AM    <DIR>          .
04/11/2013  10:53 AM    <DIR>          ..
04/11/2013  10:53 AM    <DIR>          x64
               0 File(s)              0 bytes

 Directory of \\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy\Tools\x64

04/11/2013  10:53 AM    <DIR>          .
04/11/2013  10:53 AM    <DIR>          ..
08/30/2012  06:10 PM           325,272 ��������.dll
               1 File(s)        325,272 bytes

     Total Files Listed:
               1 File(s)        325,272 bytes
               8 Dir(s)  70,546,321,408 bytes free

And in PowerShell too:

PS C:\> pushd \\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy
PS Microsoft.PowerShell.Core\FileSystem::\\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy> ls -r


    Directory: \\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         4/11/2013  10:53 AM            Tools


    Directory: \\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy\Tools


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         4/11/2013  10:53 AM            x64


    Directory: \\localhost\c$\@GMT-2013.08.27-04.01.18\Deploy\Tools\x64


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         8/30/2012   6:10 PM     325272 ��������.dll

It looks like the folder with a magic name @GMT-2013.08.27-04.01.18 (presumably representing a timestamp in the GMT time zone) behaves as if it actually existed there, except that you cannot discover its existence using the dir command unless you already know its name. All files and folders below this folder are read-only: nothing can be created, deleted, renamed or changed there (including file/folder attributes and permissions). If you are an administrator, but do not have permissions to view certain files, you cannot change that, unless you first manage to copy a containing folder to a non-readonly location.

Question: Is it possible to get the list of versions of a certain folder, like the one shown on the first screenshot, and open one of
them in a new Explorer window programmatically (using PowerShell, WMI, WSH, BAT,
Win32 API, etc)? Is it possible to get the list of corresponding
folders with magic names like @GMT-2013.08.27-04.01.18
programmatically?

Best Answer

The volrest utility, available from the Windows Server 2003 Resource Kit Tools, can be used to list the previous versions of a folder. It worked for me on Windows 7 and should still work on Windows 8. Just be careful with your parameters, since it can also restore previous versions.

An example of use (from the below-quoted link):

C:\>volrest "\\test220\reports\Annual Reports 2004\doc.4.rtf"

VOLREST 1.1 - Previous Version command-line tool
(C) Copyright 2003 Microsoft Corp.

 Searching previous versions on \\test220\reports\annual report 2004\doc.4.rtf

07/01/2004  01:28 PM    37,786 \\test220\reports\@GMT-2004.07.01-18.34.35\annual 
                           report 2004\doc.4.rtf
07/01/2004  01:27 PM    37,740 \\test220\reports\@GMT-2004.07.01-18.28.02\annual 
                           report 2004\doc.4.rtf
07/01/2004  11:47 AM    37,690 \\test220\reports\@GMT-2004.07.01-18.24.41\annual 
                           report 2004\doc.4.rtf

            3 File(s)  113,216 bytes
            0 Dir(s)

With the output of this program, maybe used with the /B parameter for bare format, you should be able to construct a script that will explore one of the listed versions.

For more info see : Windows Server Hacks: Restoring Shadow Copies Using the Command Line.

Related Question