Advertisement
Guest User

StackOverFlow

a guest
Nov 18th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Define parameters from text file
  2. cd D:\Desktop\
  3.  
  4. # Declare an Array to store image paths
  5. $imageArray = @()
  6. $locationArray = @()
  7.  
  8. # Calculate number of lines within text file
  9. $lines = Get-Content -Path PostBackupCheck-Textfile.txt  | Measure-Object -Line
  10.  
  11. # Using the .Lines member, create a loop for general functionality.
  12. for ($i=0; $i -le $lines.Lines; $i++)
  13.     {Write-Host "Stage 1: Enumerate Backup Image Information via Powershell"
  14.    
  15.     #______________________________________________________________________________________
  16.     # Work out drive letter not in use we can mount our SPI to via Function.
  17.     #
  18.     function Get-NextFreeDrive {
  19.     # Pipes letters C-Z into For Loop appending ':'
  20.         68..90 | ForEach-Object { "$([char]$_):" } |
  21.             # Test Exclusions from there Where-Object piped into the System.IO call.
  22.             Where-Object { 'h:', 'k:', 'z:' -notcontains $_ } |
  23.                 Where-Object {
  24.                     (new-object System.IO.DriveInfo $_).DriveType -eq 'noRootdirectory'
  25.                 }
  26.     }
  27.     #
  28.     #______________________________________________________________________________________
  29.    
  30.     # Assign variable the function call value piped into a Select first cmdlet.  
  31.     $drvWeCanUse = (Get-NextFreeDrive) | select -first 1
  32.    
  33.     # Scan folders to parse the latest incremental image based on the ShadowProtect naming convention
  34.     # Pass this value to a variable pre-defined and utilise this to mount the ShadowProtect Image Chain via Smart Mount
  35.    
  36.     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" }
  37.  
  38.     $shadowProtectDataLocation = $locationArray[$i]
  39.     $latestIncremental = Get-ChildItem -Path ${shadowProtectDataLocation}\*.* -Include *.spi | Sort-Object LastAccessTime -Descending | Select-Object -First 1
  40.     echo Latest' 'Incremental:' '$latestIncremental
  41.            
  42.    
  43.     $locationArray = @()
  44.     $imageArray = @()
  45.        
  46.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement