Robocopy \\server1\data \\server2\data /eīut Robocopy doesn’t just do simple copying.If you want to copy an entire folder, but don’t want to keep the permissions or delete anything from the destination folder, you could use the following command: It is perfect for copying to blank destinations but is potentially hazardous if there is already data there. Because it’s creating a mirror, it will also delete anything in the destination that doesn’t match the source. This will create an exact copy of the source folder structure, including all permissions and time stamps. Robocopy \\server1\data \\server2\data /mir /copyall /dcopy:T.If you want to copy folder DATA on Server1 to Server2, for instance, you could use this command: You can run Robocopy from your workstation, specifying the source and destination file servers, but running it directly on one of the servers will be faster and will generate less network traffic. With Robocopy you can copy a single file, stripping all permissions, mirror an entire drive while keeping all NTFS permissions in place, and pretty much anything in between.
It’s been around since Windows Server 2003 and is a very powerful tool. If you only want to copy some of the files to a server, you will probably want to use Robocopy.
How to Copy Files to a Server Using Robocopy If that is your goal, it’s easy to do and works well. This is only viable if you want all of the files and all of the same permission settings. In the modern world of Virtual Machines, another option is to just make a copy of the entire VM file and then attach that as a secondary drive to the destination server. There are several good third-party tools out there to enhance Explorer, but most admins prefer to keep their servers as lean and clean as possible. But Windows Explorer doesn’t have any real error handling or logging, so if anything goes wrong, you end up having to guess what caused the problem. If you don’t like the command line, you could just drag and drop the files to the new server. The information below assumes that both of your servers are on the same domain. The method you choose will depend on your situation and your personal preferences. As with most things in IT, there are many ways to accomplish this task.
We then pipe the doc to | Out-File where it will export it to the specified path, which comes right after the cmdlet.Copying files from one server to another is a fairly frequent task that system administrators face. If you leave this out, you’ll get all of the information of the file or folder, which is a lot of info!
You could use -File and get only files, or leave this out to get both Directory means we only want directories. Recurse means we want to continually loop through each subdirectory. You can learn more about Get-ChildItem here:Īfterwards comes your path, be sure and put it in quotes if there are spaces. It is just like “dir” or “ls” where it’s main job is to tell you the contents of a folder. Get-ChildItem \\FS01\Shared -Recurse -Name -Directory | Out-File "C:\misc\Folders.csv"
We’ll be using the Get-ChildItem cmdlet to accomplish this. This script will use PowerShell to export a list of folders to a CSV file. Here’s a quick script to list all of the folders on a share or on a server.