How will Powershell handle files that have paths too long for a destination folder on an external drive

Hello Powershell Experts,

I was waiting for a friend at his office to get a ride home.  Before we left, he said he had to copy some files off a server and onto an external hard drive.  He opened Windows Explorer and proceeded to copy his files from the server and paste them on the external drive into a folder which he created named “Copy 12-5-17”.  A few minutes later, he received a message stating that some of the files paths would be too long for the destination.  He was given an option to skip the file or cancel.  He put a checkmark in the  “do this for all files” box and clicked on the skip button and we took off.  On the way home I learned that he did this manual process every night before heading out.  Since I’m hitting this friend up for a ride home each night for a couple of weeks, I thought I would repay his kindness by trying to automate his manual process.  The server he is a Windows Server 2012 Essentials box.  The external hard drive is connected via USB and has a folder with a share name of BackupCopies on it.  I want to use Powershell to automate this manual copy process.  Here is what I have:

$Date = Get-Date -Format MM-dd-yyyy
$BackupDirectory = "\\FileServer1\BackupCopies\Copy $Date"

if (-not(Test-Path $BackupDirectory))
    {
     New-Item -ItemType Directory -Path $BackupDirectory
     Copy-Item -Path D:\Work -Destination $BackupDirectory -Recurse -Force -ErrorAction SilentlyContinue
     Copy-Item -Path D:\Common -Destination $BackupDirectory -Recurse -Force -ErrorAction SilentlyContinue
     Copy-Item -Path D:\UserShares -Destination $BackupDirectory -Recurse -Force -ErrorAction SilentlyContinue
    }
else
    {
        Break
    }


Here are my questions:
1.       What will happen to the files that triggered the “file path too long” messages (where he just hits skip) when the copy via Powershell comes to them?  The script code has the –force and –erroraction silentlycontinue switches.  Will Powershell just skip over the files?
LVL 1
ndalmolin_13Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Zaheer IqbalTechnical Assurance & ImplementationCommented:
I would use Robocopy to get around long file paths.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Zaheer IqbalTechnical Assurance & ImplementationCommented:
0
sirbountyCommented:
I second the robocopy route - a one liner that you can easily setup in scheduled tasks.  Very simple.
1
ndalmolin_13Author Commented:
Robocopy did the trick.  Thanks
1
Zaheer IqbalTechnical Assurance & ImplementationCommented:
Excellent ;)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.