I wonder if someone would look over this issue for me, this is my first complex script
Long story short, built new 2012 RDS Farm and need to move selected user files (Desktop, Documents) from the old terminal servers to a central repository where it can be GP mapped as a drive so the users can choose what they want to keep and remove after a month or so.
So, with PS I have extracted a list users from AD and created a folder for each user with sub-folders named as each of the old terminal servers on a central repository - EXAMPLE
Now I need to get the user files from the selected folders on the old terminal servers and copy them to the correct user folder and respective old terminal server - EXAMPLE
\terminal01\C$\Users\fred.blogs\Desktop* copies over to \newrepository01\old_ts_data\fred.blogs\terminal01\Desktop
I have written a PS script to import a csv with a full list of our AD users in first.last format all in one column with a heading of USER - EXAMPLE
the script then sets the old and the new path and Ive used Join-Path and Copy-Item to get the contents over
This all works nicely except its not creating the folder “Desktop” and, more annoyingly, only getting the last name in the list and I really don’t understand why.
I am probably doing something overcomplicated or just missing something stupid.
Can someone please look at this and see if they can fathom it out for me. (have replaced real path names to make the above examples work)
$listPath = “C:\Temp\test.csv”
$username = ($line.USER)
$old = “\terminal01\C$\Users$username\Desktop*”
$new = “\newrepository\G$\old_ts_data$username\terminal01”
$list = import-csv $listPath
foreach($line in $list)
$path = Join-Path $old -childpath $user.username
copy-item $path $new -recurse -force