Advertisement
Workspace-Guru

SyncPVSDisk

Mar 18th, 2018
6,980
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #### User Parameters
  2. $StorePath1 = "\\PVSSERVER01\E$"
  3. $StorePath2 = "\\PVSSERVER02\E$"
  4. $Date = Get-Date -format yyyy-MM-dd
  5. $Diskname = "VDIwin10-1703-3DPRO-$date"
  6.  
  7. #### Script Parameters
  8. $file1 = "$StorePath1\$Diskname.vhdx"
  9. $file2 = "$StorePath2\$Diskname.vhdx"
  10. $pvp1 = "$StorePath1\$Diskname.pvp"
  11. $pvp2 = "$StorePath2\$Diskname.pvp"
  12. $store1 = "$StorePath1"
  13. $store2 = "$StorePath2"
  14.  
  15. #### Check Disk location and copy
  16. $testfile1 = $file1 | test-path
  17.  
  18. if ($testfile1 -eq $False){
  19.  
  20. Write-Host "Disk not found on location $file1"
  21. Write-Host "Copy disk from location $file2"
  22.  
  23. Copy-Item -Path $file2 -Destination $store1
  24. Copy-Item -Path $pvp2 -Destination $store1
  25.  }
  26.  
  27. $testfile2 = $file2 | test-path
  28.  
  29. if ($testfile2 -eq $False){
  30.  
  31. Write-Host "Disk not found on location $file2"
  32. Write-Host "Copy disk from location $file1"
  33.  
  34. Copy-Item -Path $file1 -Destination $store2
  35. Copy-Item -Path $pvp1 -Destination $store2
  36. }
  37.  
  38. #### Check Disk size and copy
  39. $length1 = Get-Item -Path $file1 | select length
  40. $length2 = Get-Item -Path $file2 | select length
  41.  
  42. if ($length1 -like $length2){
  43.  
  44. write-host "Disk is in sync"
  45.  
  46. } else{
  47.  
  48. write-host "Disk is not in sync"
  49.  
  50. if ($length1.Length -gt $length2.Length){
  51.  
  52.     write-host "$file1 is larger then $file2"
  53.  
  54.     write-host "Delete $file2 and $pvp2"
  55.  
  56.     remove-item -Path $file2 -Force
  57.     remove-item -Path $pvp2 -Force
  58.  
  59.     write-host "Copy $file1 too $store2"
  60.  
  61.     Copy-Item -Path $file1 -Destination $store2
  62.     Copy-Item -Path $pvp1 -Destination $store2
  63.    
  64.    
  65.     }
  66.  
  67. if ($length2.Length -gt $length1.Length){
  68.  
  69.     write-host "$file2 is larger then $file1"
  70.    
  71.     write-host "Delete $file1"
  72.  
  73.     remove-item -Path $file1 -Force
  74.     remove-item -Path $pvp1 -Force
  75.  
  76.     write-host "Copy $file2 too $store1"
  77.  
  78.     Copy-Item -Path $file2 -Destination $store1
  79.     Copy-Item -Path $pvp2 -Destination $store1
  80.    
  81.     }
  82.  
  83. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement