René's URL Explorer Experiment


Title: Copy-Item incorrect behavior and also inconsistent results when rerun · Issue #10458 · PowerShell/PowerShell · GitHub

Open Graph Title: Copy-Item incorrect behavior and also inconsistent results when rerun · Issue #10458 · PowerShell/PowerShell

X Title: Copy-Item incorrect behavior and also inconsistent results when rerun · Issue #10458 · PowerShell/PowerShell

Description: Steps to reproduce Issue Copy-Item behavior is inconsistent and produces unexpected results In some cases rerunning the same command produces different results The results are different than what cmd copy, xcopy, and robocopy would produ...

Open Graph Description: Steps to reproduce Issue Copy-Item behavior is inconsistent and produces unexpected results In some cases rerunning the same command produces different results The results are different than what c...

X Description: Steps to reproduce Issue Copy-Item behavior is inconsistent and produces unexpected results In some cases rerunning the same command produces different results The results are different than what c...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/10458

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Copy-Item incorrect behavior and also inconsistent results when rerun","articleBody":"\u003c!--\r\n\r\nFor Windows PowerShell 5.1 issues, suggestions, or feature requests please use the following link instead:\r\nWindows PowerShell [UserVoice](https://windowsserver.uservoice.com/forums/301869-powershell)\r\n\r\nThis repository is **ONLY** for PowerShell Core 6 issues.\r\n\r\n- Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- Search the existing issues.\r\n- Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- Refer to the [known issues](https://docs.microsoft.com/powershell/scripting/whats-new/known-issues-ps6?view=powershell-6).\r\n\r\n-->\r\n\r\n# Steps to reproduce\r\n\r\nIssue\r\n    Copy-Item behavior is inconsistent and produces unexpected results\r\n    In some cases rerunning the same command produces different results\r\n    The results are different than what cmd copy, xcopy, and robocopy would produce\r\n\r\nSetUp\r\n    For each example the following setup is to start with a clean slate\r\n    Before EACH of the tests in EACH example the environment is reset\r\n    (so before each Copy-Item, cmd copy tests, xcopy, or robocopy test)\r\n\r\n    SetUp-PSCopyTest.ps1\r\n\r\n        rm -r -force \\test\r\n        rm -r -force \\test2\r\n\r\n        md \\test\r\n\r\n        echo 'a' > \\test\\a.txt\r\n        echo 'b' > \\test\\b.txt\r\n        echo 'c' > \\test\\c.txt\r\n        echo 'd' > \\test\\d.txt\r\n\r\n        md \\test\\1\r\n\r\n        echo '1d' > \\test\\1\\d.txt\r\n\r\n    Which produces the following folders and files\r\n\r\n        \\test\\a.txt\r\n        \\test\\b.txt\r\n        \\test\\c.txt\r\n        \\test\\d.txt\r\n        \\test\\1\r\n        \\test\\1\\d.txt\r\n\r\nExample 1  - Destination does not exist and recurse not specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n\r\n    Test\r\n        Copy-Item test test2\r\n\r\n    Expected Result\r\n        \\test2          directory created\r\n        \\test2\\a.txt    file copied\r\n        \\test2\\b.txt    file copied\r\n        \\test2\\c.txt    file copied\r\n        \\test2\\d.txt    file copied\r\n\r\n    Copy-Item Result (UnExpected)\r\n        \\test2          directory created but is empty\r\n        No files in \\test were copied\r\n\r\n    Copy-Item ReRun Result (UnExpected AND different)\r\n        \\test2\\test     directory created\r\n        No files in \\test were copied and no files exist in test2 or test2\\test\r\n\r\n    cmd copy test test2 Result (Not desired but expected)\r\n        \\test2 FILE created which contains the contents of\r\n            \\test\\a.txt\r\n            \\test\\b.txt\r\n            \\test\\c.txt\r\n            \\test\\d.txt\r\n\r\n        Not the desired result but expected since \\test2 directory did not exist\r\n\r\n    xcopy test test2 Result (Expected)\r\n        The expected results occur if you respond D for directory to the prompt\r\n        asking if test2 is File or Directory\r\n\r\n    robocopy test test2 Result (Expected)\r\n        The expected results occur\r\n\r\nExample 2  - Destination does not exist and recurse was specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n\r\n    Test\r\n        Copy-Item test test2 -r\r\n\r\n    Expected Result\r\n        \\test2                  directory created\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n        \\test\\1                 directory created\r\n        \\test\\1\\d.txt           file copied\r\n\r\n    Copy-Item Result (Expected)\r\n        The expected results occur\r\n\r\n    Copy-Item ReRun Result (UnExpected AND different)\r\n        Note when rerun the results are different since the \\test2 directory exists\r\n        This makes Copy-Item difficult to use in a script that is scheduled to run\r\n        on a reoccurring basis\r\n\r\n        \\test2\\test             directory created\r\n        \\test2\\test\\a.txt       file copied\r\n        \\test2\\test\\b.txt       file copied\r\n        \\test2\\test\\c.txt       file copied\r\n        \\test2\\test\\d.txt       file copied\r\n\r\n        \\test2\\test\\1           directory created\r\n        \\test2\\test\\1\\d.txt     file copied\r\n\r\n    Copy-Item 2nd Rerun Result (UnExpected AND different again from previous 2 runs)\r\n        Error: CopyItem : An item with the specified name \\test2\\test already exists\r\n\r\n        If -Force is specified then the results are the same as the Copy-Item ReRun results,\r\n        however, that demonstrates how Copy-Item cannot be used to produce the same results\r\n        for a rerun command. It also only seems to care when a destination directory\r\n        exists and as other tests show does not care if it would overwrite a file.\r\n\r\n    cmd copy Result (Not Supported)\r\n        cmd copy does not support recursion so test not applicable\r\n\r\n    xcopy test test2 /s /e Result (Expected)\r\n        The expected results occur if you respond D for directory to the prompt\r\n        asking if test2 is File or Directory\r\n\r\n    robocopy test test2 /s /e Result (Expected)\r\n        The expected results occur\r\n\r\nExample 3  - Destination exists but is empty and recurse not specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n        md \\test2\r\n\r\n    Test\r\n        Copy-Item test test2\r\n\r\n    Expected Result\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n\r\n    Copy-Item Result (UnExpected)\r\n        \\test2\\test             directory created\r\n        No files in \\test were copied\r\n\r\n    Copy-Item ReRun Result (UnExpected and different)\r\n        Error: copy-item : An item with the specified name \\test2\\test already exists.\r\n\r\n        If -Force is specified then the results are the same as the Copy-Item results\r\n\r\n    cmd copy test test2 Result (Expected)\r\n        The expected results occur\r\n\r\n    xcopy test test2 Result (Expected)\r\n        The expected results occur\r\n\r\n    robocopy test test2 Result (Expected)\r\n        The expected results occur\r\n\r\nExample 4  - Destination exists but is empty and recurse was specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n        md \\test2\r\n\r\n    Test\r\n        Copy-Item test test2 -r\r\n\r\n    Expected Result\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n        \\test2\\1                directory created\r\n        \\test2\\1\\d.txt          file copied\r\n\r\n    Copy-Item Result (UnExpected)\r\n        \\test2\\test\\a.txt       file copied\r\n        \\test2\\test\\b.txt       file copied\r\n        \\test2\\test\\c.txt       file copied\r\n        \\test2\\test\\d.txt       file copied\r\n        \\test2\\test\\1           directory created\r\n        \\test2\\test\\1\\d.txt     file copied\r\n\r\n    Copy-Item ReRun Result (UnExpected)\r\n        Error: Copy-Item : An item with the specified name \\test2\\test already exists.\r\n\r\n        If -Force is specified then the results are the same as the Copy-Item results, but\r\n        those are not the expected or desired results\r\n\r\n    cmd copy Result (Not Supported)\r\n        cmd copy does not support recursion so test not applicable\r\n\r\n    xcopy test test2 /s /e Result (Expected)\r\n        The expected results occur\r\n\r\n    robocopy test test2 /s /e Result (Expected)\r\n        The expected results occur\r\n\r\nExample 5  - Destination does not exist, using * with the source and recurse not specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n\r\n    Test\r\n        Copy-Item test\\* test2\r\n\r\n    Expected Result\r\n        \\test2                  directory created\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n\r\n    Copy-Item Result (Expected)\r\n        The expected results occur\r\n\r\n    Copy-Item ReRun Result (UnExpected and different)\r\n        \\test2\\1                directory created and empty\r\n\r\n        No confirmation for overwriting files occur\r\n\r\n    Copy-Item 2nd ReRun Result (UnExpected and different)\r\n        Error: Copy-Item : An item with the specified name \\test2\\1 already exists.\r\n\r\n        Interesting no issue with overwritting the files\r\n\r\n        If -Force is specified then the results are the same as the Copy-Item rerun results, but\r\n        those are not the expected or desired results\r\n\r\n    cmd copy test\\* test2 Result (Not desired but expected)\r\n        \\test2 FILE created which contains the contents of\r\n            \\test\\a.txt\r\n            \\test\\b.txt\r\n            \\test\\c.txt\r\n            \\test\\d.txt\r\n\r\n        Not the desired result but expected since \\test2 directory did not exist\r\n\r\n    xcopy test\\* test2 Result (Expected)\r\n        The expected results occur if you respond D for directory to the prompt\r\n        asking if test2 is File or Directory\r\n\r\n    robocopy test\\* test2 Result (Not supported - but alternative available)\r\n        Robocopy works with directories so this syntax is not valid\r\n        This is not really an issue since robocopy test test2 produces the expected results\r\n\r\nExample 6  - Destination does not exist, using * with the source and recurse was specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n\r\n    Test\r\n        Copy-Item test\\* test2 -r\r\n\r\n    Expected Result\r\n        \\test2                  directory created\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n        \\test2\\1                directory created\r\n        \\test2\\1\\d.txt          file copied\r\n\r\n    Copy-Item Result (UnExpected)\r\n        \\test2                  directory created\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n\r\n        Despite specifying recurse the following were not created\r\n            \\test2\\1            directory not created\r\n            \\test2\\1\\d.txt      file not copied\r\n\r\n    Copy-Item ReRun Result (Expected BUT different)\r\n        The expected results occur but this differs from the initial run which shows that\r\n        you cannot run the same command and get the same results.\r\n\r\n    cmd copy Result (Not Supported)\r\n        cmd copy does not support recursion so test not applicable\r\n\r\n    xcopy test\\* test2 /s /e Result (Expected)\r\n        The expected results occur if you respond D for directory to the prompt\r\n        asking if test2 is File or Directory\r\n\r\n    robocopy test\\* test2 /s /e Result (Not supported - but alternative available)\r\n        Robocopy works with directories so this syntax is not valid\r\n        This is not really an issue since robocopy test test2 /s /e produces the expected results\r\n\r\nExample 7  - Destination exists, using * with the source and recurse not specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n        md \\test2\r\n\r\n    Test\r\n        Copy-Item test\\* test2\r\n\r\n    Expected Result\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n\r\n    Copy-Item Result (UnExpected)\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n        \\test2\\1                directory created but empty\r\n\r\n    Copy-Item ReRun Result (UnExpected and different)\r\n        Error: Copy-Item : An item with the specified name \\test2\\1 already exists.\r\n\r\n        Interesting no issue with overwriting the files\r\n\r\n        If -Force is specified then the results are the same as the Copy-Item  results, but\r\n        those are not the expected or desired results\r\n\r\n    cmd copy test\\* test2 Result (Expected)\r\n        The expected results occur\r\n\r\n    xcopy test\\* test2 Result (Expected)\r\n        The expected results occur\r\n\r\n    robocopy test\\* test2 Result (Not supported - but alternative available)\r\n        Robocopy works with directories so this syntax is not valid\r\n        This is not really an issue since robocopy test test2 produces the expected results\r\n\r\nExample 8  - Destination exists, using * with the source and recurse was specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n        md \\test2\r\n\r\n    Test\r\n        Copy-Item test\\* test2 -r\r\n\r\n    Expected Result\r\n     \\test2\\a.txt               file copied\r\n     \\test2\\b.txt               file copied\r\n     \\test2\\c.txt               file copied\r\n     \\test2\\d.txt               file copied\r\n     \\test2\\1                   directory created\r\n     \\test2\\1\\d.txt             file copied\r\n\r\n    Copy-Item Result (Expected)\r\n        The expected results occur\r\n\r\n    Copy-Item ReRun Result (Expected If -Force is also used)\r\n        Error: Copy-Item : An item with the specified name \\test2\\1 already exists.\r\n\r\n        If -Force is specifed then the expected results occur\r\n\r\n    cmd copy Result (Not Supported)\r\n        cmd copy does not support recursion so test not applicable\r\n\r\n    xcopy test\\* test2 /s /e Result (Expected)\r\n        The expected results occur\r\n\r\n    robocopy test\\* test2 /s /e Result (Not supported - but alternative available)\r\n        Robocopy works with directories so this syntax is not valid\r\n        This is not really an issue since robocopy test test2 /s /e produces the expected results\r\n\r\nExample 9  - Destination does not exist, using *.* with the source and recurse not specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n\r\n    Test\r\n        Copy-Item test\\*.* test2\r\n\r\n    Expected Result\r\n     \\test2                     directory created\r\n     \\test2\\a.txt               file copied\r\n     \\test2\\b.txt               file copied\r\n     \\test2\\c.txt               file copied\r\n     \\test2\\d.txt               file copied\r\n\r\n    Copy-Item Result (UnExpected but similar to what cmd copy did in prior test)\r\n        test2 FILE created with the contents of \\test\\d.txt only\r\n\r\n    Copy-Item ReRun Result (UnExpected)\r\n        Same results as Copy-Item Result, however, interesting that no confirmation prompt\r\n        displayed to overwrite the file\r\n\r\n    cmd copy test\\*.* test2 Result (Not desired but expected)\r\n        \\test2 FILE created which contains the contents of\r\n            \\test\\a.txt\r\n            \\test\\b.txt\r\n            \\test\\c.txt\r\n            \\test\\d.txt\r\n\r\n    xcopy test\\*.* test2 Result (Expected)\r\n        The expected results occur if you respond D for directory to the prompt\r\n        asking if test2 is File or Directory\r\n\r\n    robocopy test\\*.* test2 Result (Not supported - but alternative available)\r\n        Robocopy works with directories so this syntax is not valid\r\n        This is not really an issue since robocopy test test2 produces the expected results\r\n\r\nExample 10 - Destination does not exist, using *.* with the source and recurse was specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n\r\n    Test\r\n        Copy-Item test\\*.* test2 -r\r\n\r\n    Expected Result\r\n        \\test2                  directory created\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n        \\test2\\1                directory created\r\n        \\test2\\1\\d.txt          file copied\r\n\r\n    Copy-Item Result (UnExpected but similar to what cmd copy did in prior test)\r\n        \\test2 FILE created which contains the contents of \\test\\d.txt\r\n\r\n    Copy-Item ReRun Result (UnExpected)\r\n        Same as Copy-Item Result but no overwrite prompt\r\n\r\n    cmd copy Result (Not Supported)\r\n        cmd copy does not support recursion so test not applicable\r\n\r\n    xcopy test\\*.* test2 /s /e Result (Expected)\r\n        The expected results occur if you respond D for directory to the prompt\r\n        asking if test2 is File or Directory\r\n\r\n    robocopy test\\*.* test2 /s /e Result (Not supported - but alternative available)\r\n        Robocopy works with directories so this syntax is not valid\r\n        This is not really an issue since robocopy test test2 /s /e produces the expected results\r\n\r\nExample 11 - Destination exists, using *.* with the source and recurse not specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n        md \\test2\r\n\r\n    Test\r\n        Copy-Item test\\*.* test2\r\n\r\n    Expected Result\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n\r\n    Copy-Item Result (Expected)\r\n        The expected results occur\r\n\r\n    Copy-Item ReRun Result (Expected)\r\n        The expected results occur, however, there is no warning about overwritting files\r\n\r\n    cmd copy test\\*.* test2 Result (Expected)\r\n        The expected results occur\r\n\r\n    xcopy test\\*.* test2 Result (Expected)\r\n        The expected results occur\r\n\r\n    robocopy test\\*.* test2 Result (Not supported - but alternative available)\r\n        Robocopy works with directories so this syntax is not valid\r\n        This is not really an issue since robocopy test test2 produces the expected results\r\n\r\nExample 12 - Destination exists, using *.* with the source and recurse was specified\r\n    Setup\r\n        SetUp-PSCopyTest.ps1\r\n        md \\test2\r\n\r\n    Test\r\n        Copy-Item test\\*.* test2 -r\r\n\r\n    Expected Result\r\n    \\test2\\a.txt                file copied\r\n    \\test2\\b.txt                file copied\r\n    \\test2\\c.txt                file copied\r\n    \\test2\\d.txt                file copied\r\n    \\test2\\1                    directory created\r\n    \\test2\\1\\d.txt              file copied\r\n\r\n    Copy-Item Result (UnExpected)\r\n        \\test2\\a.txt            file copied\r\n        \\test2\\b.txt            file copied\r\n        \\test2\\c.txt            file copied\r\n        \\test2\\d.txt            file copied\r\n\r\n        Despite specifying recurse the following were not created\r\n            \\test2\\1            directory not created\r\n            \\test2\\1\\d.txt      file not copied\r\n\r\n    Copy-Item ReRun Result (UnExpected)\r\n        Same results as Copy-Item, however, there is no warning about overwritting files\r\n\r\n        Despite specifying recurse the following were not created\r\n            \\test2\\1            directory not created\r\n            \\test2\\1\\d.txt      file not copied\r\n\r\n    cmd copy Result (Not Supported)\r\n        cmd copy does not support recursion so test not applicable\r\n\r\n    xcopy test\\*.* test2 /s /e Result (Expected)\r\n        The expected results occur\r\n\r\n    robocopy test\\*.* test2 /s /e Result (Not supported - but alternative available)\r\n        Robocopy works with directories so this syntax is not valid\r\n        This is not really an issue since robocopy test test2 /s /e produces the expected results\r\n\r\n--\r\n-- Comparison of copy method results\r\n--\r\n\r\n    Copy-Item\r\n        1   UnExpected result and different results when rerun\r\n        2   Expected result   but different results when rerun\r\n        3   UnExpected result and different results when rerun\r\n        4   UnExpected result and different results when rerun\r\n        5   Expected result   but different results when rerun\r\n        6   UnExpected result initially and Expected Result when rerun\r\n        7   UnExpected result and different results when rerun\r\n        8   Expected result   and same result when rerun if -Force used\r\n        9   UnExpected result and same result when rerun\r\n        10  UnExpected result and same result when rerun\r\n        11  Expected result   and same result when rerun\r\n        12  UnExpected result and same result when rerun\r\n\r\n    cmd copy\r\n        1   Not desired but expected result\r\n        2   Does not support recursion\r\n        3   Expected result\r\n        4   Does not support recursion\r\n        5   Not desired but expected result\r\n        6   Does not support recursion\r\n        7   Expected result\r\n        8   Does not support recursion\r\n        9   Not desired but expected result\r\n        10  Does not support recursion\r\n        11  Expected result\r\n        12  Does not support recursion\r\n\r\n    xcopy\r\n        1   Expected result\r\n        2   Expected result\r\n        3   Expected result\r\n        4   Expected result\r\n        5   Expected result\r\n        6   Expected result\r\n        7   Expected result\r\n        8   Expected result\r\n        9   Expected result\r\n        10  Expected result\r\n        11  Expected result\r\n        12  Expected result\r\n\r\n    robocopy\r\n        1   Expected result\r\n        2   Expected result\r\n        3   Expected result\r\n        4   Expected result\r\n        5   Not Supported but alternative syntax works\r\n        6   Not Supported but alternative syntax works\r\n        7   Not Supported but alternative syntax works\r\n        8   Not Supported but alternative syntax works\r\n        9   Not Supported but alternative syntax works\r\n        10  Not Supported but alternative syntax works\r\n        11  Not Supported but alternative syntax works\r\n        12  Not Supported but alternative syntax works\r\n\r\n--\r\n-- Conclusion\r\n--\r\n\r\nWhen I first started using PowerShell back in the 2.0 days I noticed these and similar issues\r\nbut figured they would be addressed as the product matured, therefore I reverted  to using\r\ncmd copy, xcopy, and robocopy, however, I wanted to use Copy-Item since in theory it provided\r\nthe capabilites of cmd copy and xcopy all in one.\r\n\r\nIt is disappointing to see that we have version 7.0 out now in beta and they still have not been\r\naddressed basic functionality.\r\n\r\nCopy-Item produces the expected results only 33% of the time and if rerun then it only produces\r\nthe same results 16% of the time.\r\n\r\nIf it was just a matter of learning a different syntax that would be one thing, however,\r\nwhen considering common use cases (destination exists, destination does not exist, recurse\r\nthe source directory tree, don't recurse the source directory tree), there does not appear\r\nto be a syntax which handles all of those cases AND can produce the same results when rerun.\r\n\r\nThis makes Copy-Item pretty much unusable excpet for all but the most simple types\r\nof copy operations.\r\n\r\nComparing Copy-Item to the other options, cmd copy generally works (with the exception of the\r\nnot supporting recursive and a few other cases), xcopy always works, and robocopy always\r\nworks OR works with a tweak to the syntax.\r\n\r\nBack in the PS 2.0 days I considered writing my own Copy-Item replacement but wanted to use\r\nbuilt in functionality as much as possible so I did not do that.\r\n\r\nAre there any plans to address these issues?\r\n\r\nThere seem to be several key issues:\r\n\r\n1)  When the destination does not exist and you are copying more than one item it should\r\n    prompt to ask if the destination should or not the destination should be a container.\r\n    That covers both use cases where you want to copy multiple items to a single item or\r\n    where you want to copy multiple items to a container.\r\n\r\n2)  Recurse needs to be fixed so that when you specify recurse it recurses and when you\r\n    don't specify recurse it does not create empty containers/folders.\r\n\r\n3)  Why does it produce an error if a destination directory exists but not when a destination\r\n    file exists?  Based on PowerShell guidelines since overwritting a file is a destructive\r\n    operation there should be a confirmation before doing so.  Having the user change their\r\n    $ConfirmationPreference from the default of 'High' is not the solution here because\r\n    that would cause all sorts of other confirmations that do not currently occur.  Since\r\n    this constitutes destructive behavior the cmdlet should be changed to confirm.\r\n\r\nI'm sure there are other examples, but those seem to be the key areas causing the problems.\r\n\r\nThis basic functionality in the product really needs to be fixed so that we do not have\r\nto restore to using external tools to accomplish these basic tasks.\r\n\r\nAll the above was reproduced on PS 7 Preview 3 \r\n\r\n# Expected behavior\r\n\r\n```Documented with each example\r\n\r\n```\r\n\r\n# Actual behavior\r\n\r\n```Documented with each example\r\n\r\n```\r\n\r\n# Environment data\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\nName                           Value\r\n----                           -----\r\nPSVersion                      7.0.0-preview.3\r\nPSEdition                      Core\r\nGitCommitId                    7.0.0-preview.3\r\nOS                             Microsoft Windows 10.0.18362\r\nPlatform                       Win32NT\r\nPSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion      2.3\r\nSerializationVersion           1.1.0.1\r\nWSManStackVersion              3.0\r\n\r\n```none\r\n\r\n```\r\n","author":{"url":"https://github.com/JoeSalmeri","@type":"Person","name":"JoeSalmeri"},"datePublished":"2019-08-28T20:20:38Z","url":"https://github.com/PowerShell/PowerShell/issues/10458"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b30923ce-06d7-ab2d-4848-57471fbe21d4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE99A:23AED3:21DF0F:2EC5F1:6AFDA05C
html-safe-nonce94719820550903abdf284c44037a2a22646f189c7e836445e3c38001b45462b8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTlBOjIzQUVEMzoyMURGMEY6MkVDNUYxOjZBRkRBMDVDIiwidmlzaXRvcl9pZCI6IjE3NDI2NDc4MTQ5NTQ3ODY5MDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacbaed41f2388b8c2508cb9a79bf5db301040e2a5d7ef5ae653ec1df3ec08182ad
hovercard-subject-tagissue:486589100
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/10458/issue_layout
twitter:imagehttps://opengraph.githubassets.com/12f46009e6d9be2b1067cfabe5dfbaa5fe65f83069ed5a5f2667e458906aef6d/PowerShell/PowerShell/issues/10458
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/12f46009e6d9be2b1067cfabe5dfbaa5fe65f83069ed5a5f2667e458906aef6d/PowerShell/PowerShell/issues/10458
og:image:altSteps to reproduce Issue Copy-Item behavior is inconsistent and produces unexpected results In some cases rerunning the same command produces different results The results are different than what c...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJoeSalmeri
hostnamegithub.com
expected-hostnamegithub.com
Nonebc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release927a6c5ab1c32b38830f1b9d3050c0b9e9aa92e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/10458#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F10458
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F10458
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/10458
Reloadhttps://github.com/PowerShell/PowerShell/issues/10458
Reloadhttps://github.com/PowerShell/PowerShell/issues/10458
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests366 (366)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
https://github.com/PowerShell/PowerShell
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/10458
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/10458
Copy-Item incorrect behavior and also inconsistent results when rerunhttps://github.com/PowerShell/PowerShell/issues/10458#top
Issue-Metaan issue used to track multiple issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Meta%22
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get ahttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Question%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Cmdletsgeneral cmdlet issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets%22
WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine-Providers%22
https://github.com/JoeSalmeri
Joe S (JoeSalmeri)https://github.com/JoeSalmeri
on Aug 28, 2019https://github.com/PowerShell/PowerShell/issues/10458#issue-486589100
Joe S (JoeSalmeri)https://github.com/JoeSalmeri
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get ahttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Question%22
on Aug 28, 2019https://github.com/PowerShell/PowerShell/issues/10458#event-2591820041
https://github.com/iSazonov
Ilya (iSazonov)https://github.com/iSazonov
on Aug 29, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-526022043
Joe S (@JoeSalmeri)https://github.com/JoeSalmeri
Ilya (iSazonov)https://github.com/iSazonov
WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine-Providers%22
Issue-Metaan issue used to track multiple issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Meta%22
on Aug 29, 2019https://github.com/PowerShell/PowerShell/issues/10458#event-2592657960
https://github.com/JoeSalmeri
Joe S (JoeSalmeri)https://github.com/JoeSalmeri
on Aug 29, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-526251645
Ilya (@iSazonov)https://github.com/iSazonov
https://github.com/iSazonov
Ilya (iSazonov)https://github.com/iSazonov
on Aug 30, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-526481072
Joe S (@JoeSalmeri)https://github.com/JoeSalmeri
https://github.com/JoeSalmeri
Joe S (JoeSalmeri)https://github.com/JoeSalmeri
on Sep 4, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-527975546
Ilya (@iSazonov)https://github.com/iSazonov
https://github.com/iSazonov
Ilya (iSazonov)https://github.com/iSazonov
on Sep 5, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-528245154
Joey Aiello (@joeyaiello)https://github.com/joeyaiello
Steve Lee (@SteveL-MSFT)https://github.com/SteveL-MSFT
https://github.com/JoeSalmeri
Joe S (JoeSalmeri)https://github.com/JoeSalmeri
on Sep 5, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-528347275
Ilya (@iSazonov)https://github.com/iSazonov
https://github.com/iSazonov
Ilya (iSazonov)https://github.com/iSazonov
on Sep 5, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-528359157
Joe S (@JoeSalmeri)https://github.com/JoeSalmeri
https://github.com/JoeSalmeri
Joe S (JoeSalmeri)https://github.com/JoeSalmeri
on Sep 5, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-528362309
Ilya (@iSazonov)https://github.com/iSazonov
https://github.com/SteveL-MSFT
Steve Lee (SteveL-MSFT)https://github.com/SteveL-MSFT
on Oct 22, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-544778891
#5785https://github.com/PowerShell/PowerShell/issues/5785
https://github.com/JoeSalmeri
Joe S (JoeSalmeri)https://github.com/JoeSalmeri
on Oct 22, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-544980309
Steve Lee (@SteveL-MSFT)https://github.com/SteveL-MSFT
https://github.com/jvierrajrv
jvierrajrvhttps://github.com/jvierrajrv
on Oct 22, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-545006033
https://github.com/SteveL-MSFT
Steve Lee (SteveL-MSFT)https://github.com/SteveL-MSFT
on Oct 22, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-545040196
Joe S (@JoeSalmeri)https://github.com/JoeSalmeri
https://github.com/JoeSalmeri
Joe S (JoeSalmeri)https://github.com/JoeSalmeri
on Oct 22, 2019https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-545195351
Steve Lee (@SteveL-MSFT)https://github.com/SteveL-MSFT
#5785https://github.com/PowerShell/PowerShell/issues/5785
Ilya (iSazonov)https://github.com/iSazonov
WG-Cmdlets-Managementhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets-Management%22
on Nov 29, 2021https://github.com/PowerShell/PowerShell/issues/10458#event-5686518824
https://github.com/JoeSalmeri
Joe S (JoeSalmeri)https://github.com/JoeSalmeri
on Jun 3, 2022https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-1146031471
Ilya (@iSazonov)https://github.com/iSazonov
Steve Lee (@SteveL-MSFT)https://github.com/SteveL-MSFT
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-1813806572
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-1813806573
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-1813806574
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/10458#event-10975791522
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 23, 2023https://github.com/PowerShell/PowerShell/issues/10458#issuecomment-1824367279
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
completedhttps://github.com/PowerShell/PowerShell/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 23, 2023https://github.com/PowerShell/PowerShell/issues/10458#event-11047250954
Ryan Yates (kilasuit)https://github.com/kilasuit
WG-Cmdletsgeneral cmdlet issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets%22
WG-Cmdlets-Managementhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets-Management%22
on Jul 17, 2026https://github.com/PowerShell/PowerShell/issues/10458#event-28145710778
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PowerShell/issues/10458
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/10458
Issue-Metaan issue used to track multiple issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Meta%22
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get ahttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Question%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Cmdletsgeneral cmdlet issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets%22
WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine-Providers%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.