Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### User Parameters
- $StorePath1 = "\\PVSSERVER01\E$"
- $StorePath2 = "\\PVSSERVER02\E$"
- $Date = Get-Date -format yyyy-MM-dd
- $Diskname = "VDIwin10-1703-3DPRO-$date"
- #### Script Parameters
- $file1 = "$StorePath1\$Diskname.vhdx"
- $file2 = "$StorePath2\$Diskname.vhdx"
- $pvp1 = "$StorePath1\$Diskname.pvp"
- $pvp2 = "$StorePath2\$Diskname.pvp"
- $store1 = "$StorePath1"
- $store2 = "$StorePath2"
- #### Check Disk location and copy
- $testfile1 = $file1 | test-path
- if ($testfile1 -eq $False){
- Write-Host "Disk not found on location $file1"
- Write-Host "Copy disk from location $file2"
- Copy-Item -Path $file2 -Destination $store1
- Copy-Item -Path $pvp2 -Destination $store1
- }
- $testfile2 = $file2 | test-path
- if ($testfile2 -eq $False){
- Write-Host "Disk not found on location $file2"
- Write-Host "Copy disk from location $file1"
- Copy-Item -Path $file1 -Destination $store2
- Copy-Item -Path $pvp1 -Destination $store2
- }
- #### Check Disk size and copy
- $length1 = Get-Item -Path $file1 | select length
- $length2 = Get-Item -Path $file2 | select length
- if ($length1 -like $length2){
- write-host "Disk is in sync"
- } else{
- write-host "Disk is not in sync"
- if ($length1.Length -gt $length2.Length){
- write-host "$file1 is larger then $file2"
- write-host "Delete $file2 and $pvp2"
- remove-item -Path $file2 -Force
- remove-item -Path $pvp2 -Force
- write-host "Copy $file1 too $store2"
- Copy-Item -Path $file1 -Destination $store2
- Copy-Item -Path $pvp1 -Destination $store2
- }
- if ($length2.Length -gt $length1.Length){
- write-host "$file2 is larger then $file1"
- write-host "Delete $file1"
- remove-item -Path $file1 -Force
- remove-item -Path $pvp1 -Force
- write-host "Copy $file2 too $store1"
- Copy-Item -Path $file2 -Destination $store1
- Copy-Item -Path $pvp2 -Destination $store1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement