We have a PS script that currently tries to use xcopy to move some files along with all of their owners, permissions, etc.
#This copies all files in the default InetpubRoot location to a new location and transfers all ownership, permissions, etc. along with it
xcopy.exe $originalInetpubRoot $newInetPubRoot /O /X /E /H /K /F
#Variables are the old and the new filepaths for InetPubRoot
The problem is that PS doesn’t really seem to work with xcopy.exe (the script gets hung up on this step and won’t progress), so I would like to use something more native to PS like Move-Item. However, I don’t know how Move-Item works and what capabilities it has.
xcopy has a wonderful doc sheet on Microsoft’s website that lists every single switch and explains what each one does: xcopy | Microsoft Docs
/O copies file ownership and DACLs
/X copies audit settings and SACLs
/E copies all sub-directories
Understood. I am not aware of any more detailed info on Move-Item. I do know from experience that Move-Item will keep the permissions from the Source and NOT inherit in the destination. So keep that in mind. I had to massage the destination after a move to Inherit from the new location. I dont have that code in front of me now but can share that if needed when I do.
Well … define “read the help” … I have done robocopy /? many times, but NEVER noticed (or needed) the /mov option. I also admit I only use it to copy, I never really move files. So yes, I have read the help, just not very thorough