-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Milestone
Description
Move-Item's -Include, -Exclude, and -Filter parameters produce errors when they should not.
Steps to reproduce
Include:
New-Item -Name "foo.txt" -ItemType File
New-Item -Name "bar.txt" -ItemType File
Move-Item -Path ".\*" -Destination "move.txt" -Include "bar*"Exclude:
New-Item -Name "foo.txt" -ItemType File
New-Item -Name "bar.txt" -ItemType File
Move-Item -Path ".\*" -Destination "move.txt" -Exclude "bar*"Filter:
New-Item -Name "foo.txt" -ItemType File
New-Item -Name "bar.txt" -ItemType File
Move-Item -Path ".\*" -Destination "move.txt" -Filter "bar*"Expected behavior
Include:
No error.
bar.txt should not exist anymore and there should be a new file named move.txt with the contents of bar.txt.
Exclude:
No error.
foo.txt should not exist anymore and there should be a new file named move.txt with the contents of foo.txt.
Filter:
No error.
bar.txt should not exist anymore and there should be a new file named move.txt with the contents of bar.txt.
Actual behavior
Include:
Successfully moves bar.txt to move.txt, but produces the following errors.
PS F:\test> Move-Item -Path .\* -Destination move.txt -Include "bar*"
Move-Item : Cannot move item because the item at 'F:\test\foo.txt' does not exist.
At line:1 char:1
+ Move-Item -Path .\* -Destination move.txt -Include "bar*"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Move-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.MoveItemCommandExclude:
Successfully moves foo.txt to move.txt, but produces the following errors.
PS F:\test> Move-Item -Path .\* -Destination move.txt -Exclude "bar*"
Move-Item : Cannot move item because the item at 'F:\test\bar.txt' does not exist.
At line:1 char:1
+ Move-Item -Path .\* -Destination move.txt -Exclude "bar*"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Move-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.MoveItemCommandFilter:
Successfully moves bar.txt to move.txt, but produces the following errors.
PS F:\test> Move-Item -Path .\* -Destination move.txt -Filter "bar*"
Move-Item : Cannot create a file when that file already exists
At line:1 char:1
+ Move-Item -Path .\* -Destination move.txt -Filter "bar*"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (F:\test\foo.txt:FileInfo) [Move-Item], IOException
+ FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Commands.MoveItemCommandEnvironment data
PS F:\test> $PSVersionTable
Name Value
---- -----
PSRemotingProtocolVersion 2.3
BuildVersion 3.0.0.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
PSVersion 6.0.0-alpha
GitCommitId v6.0.0-alpha.10
CLRVersion
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}mklement0
Metadata
Metadata
Assignees
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues