troubleshooting Question

Powershell copy folder, attributes, and hidden files.

Avatar of tomfontanilla
tomfontanillaFlag for United States of America asked on
Scripting LanguagesVB ScriptPowershell
14 Comments1 Solution4816 ViewsLast Modified:
I would to create a powershell command to copy the  folder, attributes, and hidden files. After copying the  folder, attributes, and hidden files, next time the command run, it should only copy the new files, attributes, and hidden files for that folder. In addition, It should create logs progress info.

so far this is what I have.

$source = "C:\VeraSMART Data\Archives"
$filter = "*.arc"
$date = (get-date)
$destination = "\\file4\d$\eCASBackup\eCASBak"
$logProgress = 'c:\crmz3\logs\backupLog.txt'
$size = 0
$num = 0
ls -path $source -fi $filter | sort-object LastWriteTime | select-object -last 1 | foreach {
$fileobj = $_
copy $fileobj.fullname -recurse $destination -errorAction silentlyContinue -ErrorVariable err 2> "$(get-date -f yyyy-MM-dd)-Logfile.txt"
if($? -eq $false){echo "$date $source failed backup to $destination" | out-file -append $logProgress}
else
{
$size += $fileobj.Length
$num += 1
echo "$date $source Backup is successfully copied to $destination" | out-file -append $logProgress}
$size
$num
echo "Total size of files is:  $size" | out-file -append $logProgress
echo "Total num of folder is:  $num" | out-file -append $logProgress}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 14 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros