Question

I want to move the Favorites folder from a folder that changes its folder guid daily from Appsense.

Text between quotes changes.

C:\appsensevirtual\S-1-5-21-220523388-2000478354-839522115-60875\'{647CFC75-E4C0-4F13-9888-C37BA083416C}'\_Microsoft Office 2010

I have found this but it never copies to the H: (Homedrive).

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

If i run I get this in an Powershell Administrator Window (powershell 2)

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
Was it helpful?

Solution

You solution is:
Remove -Directory from your command, and add -Force which will parse system & hidden folders.

Get-ChildItem "C:\Appsensevirtual" -Recurse -Filter "Favorites*" -Force |
Move-Item -Destination "H:\Favorites"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top