This script is copying files and is maintaining the lastwritetime which is important. However, everything is getting dumped into the root of my destination folder rather than maintaining directory structure. I read on scripting guy that the -containiner would make things go where they came from, but it's not working.
I have to use the subst t: because my file names are to long otherwise.
Copy-Item will only maintain the directory structure if you're copying an entire folder from one place to another. What you're actually doing is copying a bunch of files, piping each one individually into the same destination.
In practice, I'd probably just use robocopy.exe for this, since it has everything you need anyway. But if you want to use PowerShell with Get-ChildItem and Copy-Item, you'll need to figure out the full target path yourself. I do this in several bits of my own code, using this Get-RelativePath function: