Windows 搜索文件夹中的文件夹并将其移动到新目标

Windows 搜索文件夹中的文件夹并将其移动到新目标,windows,powershell,windows-7,Windows,Powershell,Windows 7,我想从每天从Appsense更改文件夹guid的文件夹中移动收藏夹文件夹 引号之间的文本会发生变化 C:\appsensevirtual\S-1-5-21-220523388-2000478354-839522115-60875\'{647CFC75-E4C0-4F13-9888-C37BA083416C}'\_Microsoft Office 2010 我找到了这个,但它从未复制到H:(Homedrive) 如果我运行,我会在Powershell管理员窗口(Powershell 2)中获得此

我想从每天从
Appsense
更改文件夹guid的文件夹中移动收藏夹文件夹

引号之间的文本会发生变化

C:\appsensevirtual\S-1-5-21-220523388-2000478354-839522115-60875\'{647CFC75-E4C0-4F13-9888-C37BA083416C}'\_Microsoft Office 2010
我找到了这个,但它从未复制到H:(Homedrive)

如果我运行,我会在Powershell管理员窗口(Powershell 2)中获得此信息

PS C:\temp>\favorites.ps1
Get ChildItem:找不到与参数名称“Directory”匹配的参数。
在C:\temp\favorites.ps1:1 char:76
+获取子项“C:\Appsensevirtual”-递归-筛选“收藏夹*”-目录您的解决方案是:
从命令中删除
-Directory
,并添加将解析系统和隐藏文件夹的
-Force

Get-ChildItem "C:\Appsensevirtual" -Recurse -Filter "Favorites*" -Force |
Move-Item -Destination "H:\Favorites"

Get-ChildItem命令是否返回某些内容?由于我没有在提到的任何路径中看到偏好,我们可以有一个真实的示例吗?编辑了我的帖子,感谢您的时间,因为您的问题是
-目录
参数不存在(您是否阅读了错误消息?)。若要仅筛选Get ChildItem中的文件夹,您需要将-Directory替换为
| Where对象{$\u.PsIsContainer}
(隐含的
-eq$True
)。在不移动的情况下进行测试,看看它是否找到了所需的文件夹。是的,但没有powershell经验,我是个傻瓜。所以你想让我运行:-Get ChildItem“C:\Appsensevirtual”-Recurse-Filter“Favorites*”| | Where对象{$$.PsIsContainer}(隐含-eq$True)“H:\Favorites”,所以我运行了下面的行,它没有返回任何信息或错误Get ChildItem“C:\Appsensevirtual”-Recurse | Where对象{$$.psiContainer}谢谢,这就是我移动项目时遇到的错误:源路径和目标路径必须具有相同的根。移动在卷之间不起作用。在第1行char:84+Get ChildItem“C:\Appsensevirtual”-Recurse-Filter“Favorites*”-Force | Move Item Matt这现在可以工作到我的C:\:)我在C:\Appsensevirtual文件夹中,一旦我从C:运行了命令,我就可以将文件从C:复制到h:。非常感谢你的帮助和帮助patience@AdiGraham:如果答案合适,别忘了标记为答案。这将有助于下一个遇到同样问题的人。嗨,马特,刚刚又尝试了一次,根本没有工作,只是转到下一行,想知道之前是否已经制作了文件夹-我的测试机一团糟@AdiGraham:尝试添加-force,以处理文件夹已经存在的情况。告诉我们它是否有效
PS C:\temp> .\favorites.ps1
Get-ChildItem : A parameter cannot be found that matches parameter name 'Directory'.
At C:\temp\favorites.ps1:1 char:76
+ Get-ChildItem "C:\Appsensevirtual" -Recurse -Filter "Favorites*" -Directory <<<<  | Move-Item -Destination "H:\Favorites"
    + CategoryInfo          : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem "C:\Appsensevirtual" -Recurse -Filter "Favorites*" -Force |
Move-Item -Destination "H:\Favorites"