Need Help writing a Script to use Robocopy

Mike Carter 246 Reputation points
2020-12-15T18:21:16.65+00:00

I have been trying to google how to do this and I am having trouble finding a good example that helps me learn how to do this.

I need a Script that will run a Robocopy command on a list of about 530 users. The RoboCopy command I need to run is

Robocopy "D:\homedrive\$username\Chrome" "D:\Chrome\$username" /e

the user names I need to run this against will be in a CSV file in a single column "username"

can get some help from the Script writers out there to make this work?

the Script will be ran on the server the files are being moved on.

Thank you.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,462 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 45,906 Reputation points
    2020-12-15T19:20:20.717+00:00

    Try this:

    Import-Csv X:\SomeDirectory\SomeFileName.csv |
        ForEach-Object{
            $cmdArgs = "D:\homedrive\$($_.username)\Chrome", "D:\Chrome\$($_.username)", "/e"
            Robocopy $cmdArgs
    
        }
        
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful