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
The Move-Item doc on Microsoft’s website does not have any of this information: Move-Item (Microsoft.PowerShell.Management) - PowerShell | Microsoft Docs
The closest item is using the -Recurse switch to include all child items.
So my question is: does Move-Item have the same capabilities as xcopy? If so, how do I use them? If not, is there a way to get xcopy to work correctly in my PS script?