Hi Chaps. Got an issue with a foreach
So I have a CSV file and lets say it just has two usernames. TESTUser1 and TestUser2. When the script is running its copying TestUser1 profile successfully and then it should move some folders based on that users copied data. What it looks to be doing is copying TestUser1 successfully and its then trying to move the data based on TestUser2 but that profile has not even copied yet.
Once its copied both profiles if i comment out Copy-Item -Recurse -Path U:$User $MigrationFolder -Force and run the script it moves the data successfully on both profiles. Am I missing a trick here with the foreach?
$MigrationFolder = "D:\Migration-Folder"
$MyPictures = "$User\Documents\My Pictures"
$Desktop = "$User\Redirected\Desktop"
$Downloads = "$User\Redirected\Downloads"
$DestinationFolder = "$User"
foreach($User in (Get-Content -Path D:\Users.csv)){
#Copy CSV username H:\ to a migration folder
Copy-Item -Recurse -Path U:\$User $MigrationFolder -Force
#Move My Pictures to the root folder
Move-Item -path $MigrationFolder'\'$MyPictures $MigrationFolder'\'$DestinationFolder -Force
#Move Desktop to the root folder
Move-Item -path $MigrationFolder'\'$Desktop $MigrationFolder'\'$DestinationFolder -Force
#Move Downloads to the root folder
Move-Item -path $MigrationFolder'\'$Downloads $MigrationFolder'\'$DestinationFolder -Force
}