question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prerequisites

Steps to reproduce

PowerShell 7.4.0 Preview 1 Can no longer use robocopy.exe from powershell. As robocopy.exe returns status code other than 0 for successful copies.

Repro:

  1. robocopy .\PowerShell-7.4.0-preview.1-win-x64\ .\temp\

Expect: Runs without creating an error object.

Actual: Creates Error Object NativeCommandExitException: Program “Robocopy.exe” ended with non-zero exit code: 1.

Issue: This will break all of our existing automation. We use robocopy everywhere. And our scripts all use ErrorAction = Stop

Expected behavior

robocopy .\PowerShell-7.4.0-preview.1-win-x64\ .\temp\

# Files are copied. No error is raised when all files are copied.

Actual behavior

robocopy .\PowerShell-7.4.0-preview.1-win-x64\ .\temp\
 # An error is raised even though robocopy detected no errors.
 # 1 indicates all files copied.

Error details

PS > Get-Error

Exception             :
    Type        : System.Management.Automation.NativeCommandExitException
    Path        : C:\Windows\system32\Robocopy.exe
    ExitCode    : 1
    ProcessId   : 17460
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Program "Robocopy.exe" ended with non-zero exit code: 1.
            HResult : -2146233087
        CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : ProgramExitedWithNonZeroCode
    Message     : Program "Robocopy.exe" ended with non-zero exit code: 1.
    HResult     : -2146233087
TargetObject          : C:\Windows\system32\Robocopy.exe
CategoryInfo          : NotSpecified: (C:\Windows\system32\Robocopy.exe:String) [], NativeCommandExitException
FullyQualifiedErrorId : ProgramExitedWithNonZeroCode

Environment data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.1
PSEdition                      Core
GitCommitId                    7.4.0-preview.1
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

Steps.zip

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Reactions:3
  • Comments:27 (15 by maintainers)

github_iconTop GitHub Comments

3reactions
SteveL-MSFTcommented, Jan 30, 2023

@jazzdelightsme I believe it was mentioned in a separate issue that $PSNativeCommandUseErrorActionPreference is default to $false and only set to $true in 7.4 previews to get feedback.

1reaction
sba923commented, Aug 2, 2023

@sba923, the current behavior is a bit counter-intuitive:

This is indeed far from intuitive…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Robocopy command is not copying files and folders
Try Below robocopy "Source" "destination" /MIR /E /XO /xx /tee /R:2 /W:1 /SEC /LOG:"o/p path". MIR - mirrors directory - deletes files which ......
Read more >
[SOLVED] Robocopy not working - PowerShell
I am looking for a simple script to move files older than 2 days old, from a Windows 7 on domain workstation, to...
Read more >
Robocopy broken in Win 10 v2004?
Is robocopy in Win 10 v2004 totally borked? I have been using a batch file for 5 years now to robocopy my documents,...
Read more >
windows 10 - Robocopy not working on Win10 machine
I can't get robocopy to work within a simple batch file (my first), as I keep getting ERROR 123 (0x0000007B) [below]; I've searched...
Read more >
Backup and compare with robocopy not working
I've backed up the Windows folder from a Windows 10 boot drive with robocopy F:\Windows E:\roboRubi\Windowsz /mir
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found