Robocopy For Loop
The below PowerShell script reads a text file of usernames and runs Robocopy against each user after taking ownership of the files using takeown.
$users = Get-Content C:\folder\users.txt foreach ($user in $users) { takeown /a /r /d Y /f \\server\home$\$user robocopy \\server\home$\$user \\server2\users$\$user /s /e /sec /np /v /w:5 /r:2 /xo /xf pagefile.sys /xd "System Volume Information" /log:C:\folder\$user.txt }
Back