Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Define parameters from text file
- cd D:\Desktop\
- # Declare an Array to store image paths
- $imageArray = @()
- $locationArray = @()
- # Calculate number of lines within text file
- $lines = Get-Content -Path PostBackupCheck-Textfile.txt | Measure-Object -Line
- # Using the .Lines member, create a loop for general functionality.
- for ($i=0; $i -le $lines.Lines; $i++)
- {Write-Host "Stage 1: Enumerate Backup Image Information via Powershell"
- #______________________________________________________________________________________
- # Work out drive letter not in use we can mount our SPI to via Function.
- #
- function Get-NextFreeDrive {
- # Pipes letters C-Z into For Loop appending ':'
- 68..90 | ForEach-Object { "$([char]$_):" } |
- # Test Exclusions from there Where-Object piped into the System.IO call.
- Where-Object { 'h:', 'k:', 'z:' -notcontains $_ } |
- Where-Object {
- (new-object System.IO.DriveInfo $_).DriveType -eq 'noRootdirectory'
- }
- }
- #
- #______________________________________________________________________________________
- # Assign variable the function call value piped into a Select first cmdlet.
- $drvWeCanUse = (Get-NextFreeDrive) | select -first 1
- # Scan folders to parse the latest incremental image based on the ShadowProtect naming convention
- # Pass this value to a variable pre-defined and utilise this to mount the ShadowProtect Image Chain via Smart Mount
- Get-Content -Path PostBackupCheck-TextFile.txt | Select-Object -Index $i { $a = $_ -split ' ' ; $locationArray += "$($a[0]):\$($a[1])\$($a[2])" ; $imageArray += "$($a[2])_$($a[3])_VOL_b00$($a[4])_i$($a[5]).spi" }
- $shadowProtectDataLocation = $locationArray[$i]
- $latestIncremental = Get-ChildItem -Path ${shadowProtectDataLocation}\*.* -Include *.spi | Sort-Object LastAccessTime -Descending | Select-Object -First 1
- echo Latest' 'Incremental:' '$latestIncremental
- $locationArray = @()
- $imageArray = @()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement