Jan Veselý
Jan Veselý

Reputation: 1519

Move-Item with Exclude doesn't work

I have two scripts which should do the same but the first doesn't work and the second does. Why is that? I have managed to figure out it has something to do with the Execlude. It says:

Move-Item : Cannot move item because the item at 'E:\hudba\test.ps1' does not exist. At line:1 char:1 + Move-Item "E:\test\*" "E:\ ... + CategoryInfo     : InvalidOperation: (:) [Move-Item], PSInvalidOperationException   + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.MoveItemCommand

The scripts

Move-Item "E:\test\*" "E:\test2" -Exclude "*.ps1"

Get-ChildItem -Path "E:\test\*" -Recurse -Exclude "*.ps1" | Move-Item -Destination "E:\test2"

Thank you :)

Upvotes: 2

Views: 5166

Answers (1)

Avner
Avner

Reputation: 4556

This is a known issue, and is slated for v6 to fix

https://github.com/PowerShell/PowerShell/issues/2385

Upvotes: 4

Related Questions