Published on

Intial Copy Files

Authors
  • Name
    Jackson Chen
cls


# Variables
$Computer = $env:COMPUTERNAME
$options = "/E /MT:16 /NP"
$date = Get-Date
$minute = (Get-Date -Format yyyy.MM.dd.hh.mm)
$LogFile = "\\$Computer\C$\Operations\Logs\LAB-Folder-Migration-$Computer-$minute.txt"




#*************************************************************************************************************
# *** IMPORTANT ****
# Update Source Path
# Using single quot ''

$sourcePath = '\\SourceFileSrv01\E$\Data\Folder1\Sub Folder'

# Update Destination Path
$DestPath = '\\DestFileSrv01\E$\DATA\Folder1\Sub Folder'
#*************************************************************************************************************


# ------------------------------------------------------
# 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 that the file migration has failed
    Write-Host "`nNot able to migration team files and folders, please try again." -ForegroundColor Red
}