There are times when you want to get an exact duplicate of a servers files (for DFS probably) and get an exact match of the file hash in the process. To do this you can use the following command on a local server (say you are moving the files from a local C:\ drive to a newly created I:\ drive to free up the operating system drivespace... before doing the following be sure to turn off your antivirus software scanning engine as it will result in a string of files not being able to fully copy most times!!
Open elevated command prompt on Sever (Run as Administrator) and run RoboCopy with this syntax:
All of this assumes you have the rights to the original server share and that files are not locked by users who have modified share rights to the folders in the original share? If that is the case, you will need to get onto the original share and take permissions back on the folder.
in the case of DFS if you are creating a new share and this completes your copy - then be sure to share your folder to DFS, and set rights accordingly (example - everyone = Read, Domain Admins = Full)
If you are replacing an old share you will need to get rid of the original share (though it may not delete)? If that is the case there is another process to follow. Try this - it works for me...
If the share will not clear you can still continue if needed by setting up the new share on I:\InstallPkgs to be used as the replication folder, but it will be shared as I:\InstallPkgs2 (since you are unable to clear the C:\InstallPkgs share).
Microsoft is aware of the issue with removal of DFS shares and there is a hotfix which may be applied to remove the old shares when experienced on a system, however after review it may cause other issues. It may be better to leave the old share on?
Other items to try (06/03/2016) you can do this to get rid of the share...
On each host, under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DFS\Roots\Domain in the registry, there may be old entries for original namespaces. Delete the old entries only (not your new share).
Delete the shares using the registry.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares delete the entries for the ones that were not *actively* hosted on the servers, and then delete the corresponding entries under the Security key.
No - restart the Server service and the shares should be gone.
"If the share persists" - you will have t o reboot the server to make the change effective so schedule a downtime accordingly. If you are setting up a DFS share, I will post another blog for how to enable your DFS share and not trip up your existing environment.
At this point you should be able to restart your anti-virus engine. Hope this helps!
I'm busy working on my blog posts. Watch this space!