Skip to content

Commit

Permalink
1.0.23 - Add functions to enumerate snapshots / previous versions
Browse files Browse the repository at this point in the history
  • Loading branch information
CamFlyerCH committed Mar 20, 2021
1 parent 29b63bc commit 77008f5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
10 changes: 5 additions & 5 deletions FileShareUtils/FileShareUtils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ Function Get-SnapshotItems{
Version History:
1.0 //First version 20.03.2021
OUTPUT : Array of file or folder objects with additional value SnapshotCreatedTime
OUTPUT : Array of file or folder objects with additional value SnapshotCreationTime
.EXAMPLE
Expand Down Expand Up @@ -2062,7 +2062,7 @@ Function Get-SnapshotItems{
ForEach($SnapPath in $SnapPaths){
$FolderObj = Get-Item -LiteralPath $SnapPath
$SnapshotDateTime = [datetime]::parseexact($FolderObj.Name, '@GMT-yyyy.MM.dd-HH.mm.ss', $null)
$SnapshotsFolders += $FolderObj | Select-Object *,@{n='SnapshotCreatedTime';e={$SnapshotDateTime}}
$SnapshotsFolders += $FolderObj | Select-Object *,@{n='SnapshotCreationTime';e={$SnapshotDateTime}}
}

# Search mode needs to check each snapshot for given path
Expand All @@ -2075,9 +2075,9 @@ Function Get-SnapshotItems{

IF($TestItem){
IF($TestItem.PSIsContainer){
$TempResult += $TestItem | Select-Object *,@{n='SnapshotCreatedTime';e={$SnapshotsFolder.SnapshotCreatedTime}}
$TempResult += $TestItem | Select-Object *,@{n='SnapshotCreationTime';e={$SnapshotsFolder.SnapshotCreationTime}}
} Else {
$TempResult += Get-Item -LiteralPath (Split-Path ($SnapshotsFolder.FullName + $SearchPath) -Parent) -ErrorAction SilentlyContinue | Select-Object *,@{n='SnapshotCreatedTime';e={$SnapshotsFolder.SnapshotCreatedTime}}
$TempResult += Get-Item -LiteralPath (Split-Path ($SnapshotsFolder.FullName + $SearchPath) -Parent) -ErrorAction SilentlyContinue | Select-Object *,@{n='SnapshotCreationTime';e={$SnapshotsFolder.SnapshotCreationTime}}
$SourceFile = $TestItem
}
}
Expand All @@ -2099,7 +2099,7 @@ Function Get-SnapshotItems{

# Compare Modify dates
If($LastVersionDate -ne $TestFile.LastWriteTimeUtc){
$TestFile | Select-Object *,@{n='SnapshotCreatedTime';e={$SnapshotsFolder.SnapshotCreatedTime}}
$TestFile | Select-Object *,@{n='SnapshotCreationTime';e={$SnapshotsFolder.SnapshotCreationTime}}
$LastVersionDate = $TestFile.LastWriteTimeUtc
}
}
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,33 @@ Server | The machine hosting the sessions, default is the local machine

This function returns nothing.

<br/>

#### Get-SnapshotPath [[-Path] \<string>]

With this command will return you every snapshot (path) for a given folder (on a network share).

The returned array of strings will contain the full path to the snapshots of the given folders.

<br/>

#### Get-SnapshotItems [[-Path] \<string>]

With this command will return file or folder objects found existing in snapshots for a given full path to a folder or file.
The folder/file does not need to exist at the present location. For folders every existing snapshot is listed.
For files only older versions are returned.

The returned array of objects will be of the type DirectoryInfo or FileInfo
with the additional property SnapshotCreationTime (in DateTime format).

Most usefull properties:

Property | Description
---------|----------
FullName | Full path to the object
LastWriteTime | Last modify date of the object
SnapshotCreationTime | Time (local) the snapshot was taken

<br/><br/>

## Installation
Expand Down

0 comments on commit 77008f5

Please sign in to comment.