Handle IO Exception as non-terminating (#10950)
This commit is contained in:
parent
ca68d9dbc5
commit
a3d73d751f
|
@ -3963,6 +3963,10 @@ namespace Microsoft.PowerShell.Commands
|
|||
WriteError(new ErrorRecord(unAuthorizedAccessException, "CopyFileInfoItemUnauthorizedAccessError", ErrorCategory.PermissionDenied, file));
|
||||
}
|
||||
}
|
||||
catch (IOException ioException)
|
||||
{
|
||||
WriteError(new ErrorRecord(ioException, "CopyFileInfoItemIOError", ErrorCategory.WriteError, file));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
Describe "Validate Copy-Item locally" -Tags "CI" {
|
||||
It "Copy-Item has non-terminating error if destination is in use" -Skip:(!$IsWindows) {
|
||||
Copy-Item -Path $env:windir\system32\cmd.exe -Destination TestDrive:\
|
||||
$cmd = Start-Process -FilePath TestDrive:\cmd.exe -PassThru
|
||||
try {
|
||||
{ Copy-Item -Path $env:windir\system32\cmd.exe -Destination TestDrive:\ -ErrorAction SilentlyContinue } | Should -Not -Throw
|
||||
}
|
||||
finally {
|
||||
$cmd | Stop-Process
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# This is a Pester test suite to validate Copy-Item remotely using a remote session.
|
||||
|
||||
# If PS Remoting is not available, do not run the suite.
|
||||
|
|
Loading…
Reference in a new issue