- Published on
Delta Files Sync
- Authors
- Name
- Jackson Chen
cls
# Variables
$Computer = $env:COMPUTERNAME
$options = "/XO /E /MT:16"
$date = Get-Date
$minute = (Get-Date -Format yyyy.MM.dd.hh.mm)
$LogFile = "\\$Computer\C$\Operations\Logs\LAB-Folder-Migration-Delta-Sync-$Computer-$minute.txt"
#*************************************************************************************************************
# *** IMPORTANT ****
# Update Source Path
# Required to use single quote '' for the path
$sourcePath = '\\SourceFileSrv01\E$\Data\Dir01\Sub-Dir01'
# Update Destination Path
$DestPath = '\\DestFileSrv01\E$\DATA\Group\NewDir'
#*************************************************************************************************************
# ------------------------------------------------------
# Main
# ------------------------------------------------------
Try {
# Verify the validity of the source path
If (Test-Path $SourcePath) {
$Source = "$SourcePath"
# Verify the validity of the destination path
If (Test-Path $DestPath) {
$Dest = "'$DestPath'"
# Verify the destination path is the new Team folder
Invoke-Expression "robocopy $Source $Dest $options /log:$LogFile" -ErrorAction Stop
Write-Host "`tRequired files have been copied." -ForegroundColor Green
}
Else {
Write-Host "`tThe destination path is not the valid new Team folder. Please verify." -ForegroundColor Yellow
}
}
Else {
Write-Host "`tThe Destination path is not valid. Please verify and try again." -ForegroundColor Red
}
}
Catch {
# Inform support team that the file migration has failed
Write-Host "`nNot able to migration team files and folders, please try again." -ForegroundColor Red
}