Here is a Powershell script that uses Robocopy to copy a user profile or any directory to the specified destination.
$source = "C:\Users\username\"
$timefolder='yyyy-MM-dd'
$destname = (Get-Date).ToString($timefolder)
$destination = "\\DESTINATION\$destname\"
$timeformat='yyyy-MM-dd hh:mm:ss tt'
$time = (Get-Date).ToString($timeformat)
$dircheck = Test-Path $source
#Creating Log File
$time + "Creating Log" | Out-File log.txt
#Checks if source exists
if($dircheck -eq $true) {
Write-Host "Backing up $source"
$time + "Starting Backup" | Out-File log.txt
ROBOCOPY $source $destination /COPYALL /SEC /MIR /S /E /W:3 /A-:SH| Out-file log.txt -Append
}
else {
$time + "Source does not exist" | Out-File log.txt -Append
Write-Host "Source does not exist!"
}
