Please feel free to provide feedback or file bugs here.

Move-Item's -Verbose causes $ErrorActionPreference to be ignored

Move-Items's -Verbose parameter causes the global $ErrorActionPreference = "Stop" to be ignored. This is a bug. Here's a repro script:

BugRepro.ps1:

$ErrorActionPreference = "Stop"
Write-Host "ErrorActionPreference is $ErrorActionPreference"
mkdir folder -ErrorAction SilentlyContinue | Out-Null
"" > a.txt
Copy-Item a.txt folder
Write-Host "About to trigger error"
Move-Item a.txt folder -Verbose | Out-Null
Write-Host "If you're reading this, then execution didn't stop!"
Write-Host "Remove the Verbose paramter and it does stop, like it should."

2 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    John B shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Pyprohly commented  ·   ·  Flag as inappropriate

        It’s not just limited to Move-Item. This seems to affect most, if not all, cmdlets. But it also depends on what kind of error the cmdlet throws, for instance, $ErrorActionPreference is obeyed on New-Item’s “Illegal characters in path” error but is ignored on “The file ‘…’ already exists”.

      Feedback and Knowledge Base