我正在尝试从"file"文件夹中移动数据,并排除Users
文件夹。但最后,该异常无效。
Move-Item -Path $env:SystemDrive\$env:computername\File\* -exclude $env:SystemDrive\$env:computername\File\Users\* -Destination $env:SystemDrive\UserOld\
有必要传输数据并排除
Users
文件夹。
最佳答案
我尝试使用move-item
来移动文件夹,同时排除单个文件夹,看来您不需要在排除中包括整个路径。
我尝试了这个:
Move-Item -Path C:\Users\D.Baier\Desktop\testenvironment\Source -Exclude mit-1 -Destination C:\Users\D.Baier\Desktop\testenvironment\Target\
并且它似乎运行得很好,只是据我所知抛出了一个似乎是a known issue的错误。
错误是以下顺便说一句:
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
希望对您有所帮助!
编辑:对不起,我的电脑设置为德语。我尽我所能翻译了错误消息,但是我怀疑如果您在英语机器上运行此代码,是否会得到与该错误消息完全相同的信息。对于可能犯的拼写错误,我也深表歉意。
关于powershell - move 带有文件的文件夹(异常(exception)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57159760/