powershell - move 带有文件的文件夹(异常(exception))

标签 powershell exception move

我正在尝试从"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/

相关文章:

powershell - 从另一个PowerShell session 监视PowerShell session 中的作业

powershell - 使用 Powershell 脚本调用 WebRequest

java - 使用异常从深度递归合法返回吗?

java - 是什么导致了 java.lang.ArrayIndexOutOfBoundsException 以及如何防止它?

powershell - 在目标目录的每个子目录中创建 CSV 文件

asp.net - 无法提交配置更改,因为文件在磁盘上已更改

java - 应用栏不显示后退按钮

SVN:如何将一个文件夹的内容 move 到另一个文件夹

iphone - iPhone: move 不带动画的UIButton

MySQL:使用唯一标识符将数据从一个表 move 到另一个表