From 77008f5bbe13dc4318c0469683fbc14659f3e28a Mon Sep 17 00:00:00 2001 From: CamFlyerCH Date: Sat, 20 Mar 2021 17:37:44 +0100 Subject: [PATCH] 1.0.23 - Add functions to enumerate snapshots / previous versions --- FileShareUtils/FileShareUtils.psm1 | 10 +++++----- README.md | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/FileShareUtils/FileShareUtils.psm1 b/FileShareUtils/FileShareUtils.psm1 index 50a3517..7a6f35a 100644 --- a/FileShareUtils/FileShareUtils.psm1 +++ b/FileShareUtils/FileShareUtils.psm1 @@ -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 @@ -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 @@ -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 } } @@ -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 } } diff --git a/README.md b/README.md index d84b468..2ca5b28 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,33 @@ Server | The machine hosting the sessions, default is the local machine This function returns nothing. +
+ +#### Get-SnapshotPath [[-Path] \] + +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. + +
+ +#### Get-SnapshotItems [[-Path] \] + +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 +

## Installation