I'm trying to move data from the "file" folder and exclude the Users
folder. but in the end, the exception does not work.
Move-Item -Path $env:SystemDrive\$env:computername\File\* -exclude $env:SystemDrive\$env:computername\File\Users\* -Destination $env:SystemDrive\UserOld\
It is necessary to transfer the data and exclude the Users
folder.
I tried using move-item
in order to move folders while excluding a single folder and it doesnt seem like you need to include the entire path in the exclude. I tried this:
Move-Item -Path C:\Users\D.Baier\Desktop\testenvironment\Source -Exclude mit-1 -Destination C:\Users\D.Baier\Desktop\testenvironment\Target\
and it seemed to work perfectly, just threw an error which seems to be a known issue, at least as far as I understand it. The error was the following btw:
Move-Item : The Element cannot be moved, since the Element, located at "C:\Users\D.Baier\Desktop\testenvironment\Source\mit-1" does not exist.
In Line:1 Charakter:1
+ Move-Item -Path C:\Users\D.Baier\Desktop\testenvironment\Source \* -Exclu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Move-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.MoveItemCommand
Hope that was helpful!
Edit: Sorry, my PC is set to German. I translated the error message as well as I can, however I doubt it is the exact same one one would get if you were to run this code on an English machine. I also apologize for any spelling mistakes I may have made.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments