我需要从回收站中恢复超过40000个项目,通过GUI它使用了大量内存,系统几乎挂起,即使我在100个项目时间。因此,我在PowerShell中写了下面的脚本,但我有以下错误:
VERBOSE: Performing the operation "Move Directory" on target "Item: E:\$RECYCLE.BIN\S-1-5-21-45987200-1508583899-68119131-500\$R2FXY9E Destination: E:\OneDrive - MHG - Brasil\Admin_Fin\Silvia\Silvia\Clientes\Miller Heiman Group\Embraer\Fase I\ARIBA\Embraer - Evento - Resumo_arquivos".
Move-Item : Could not find a part of the path.
At E:\Scripts\ListaRecycled.ps1:7 char:6
+ Move-Item $item.Path $CaminhoCompleto -Force -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (E:\$RECYCLE.BIN...31-500\$R2FXY9E:DirectoryInfo) [Move-Item],
DirectoryNotFoundException
+ FullyQualifiedErrorId : MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand
在我的代码,我做了以下内容:
$Shell = New-Object -ComObject Shell.Application
$Global:Recycler = $Shell.NameSpace(0xa)
$Excluidos = $Recycler.Items()
foreach ($item in $Excluidos)
{
$CaminhoCompleto = Join-Path $Recycler.GetDetailsOf($item,1) $Recycler.GetDetailsOf($item,0)
Move-Item $item.Path $CaminhoCompleto -Force -Verbose
}
感谢。
我认为您的箱子中有一个空白对象或者名称不正确。我上面试过你的代码,事实证明我有一个没有名字的文件夹(不知道它来自哪里),但是因为连接路径函数的运行方式而崩溃了。它找到了旧的路径,试图连接一个空白名称,然后试图将其移到基础文件夹。不知道这是否也是您的问题,但值得检查垃圾箱的内容以确保您没有任何空白。 –
您可以使用该项目的属性来确定目的地。 '$ item.getfolder.title' – TheMadTechnician