-
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
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Remove-Item throws Attempted to divide by zero on PS 7.5.0.preview.3 when removing items from folder where some of files are empty and locked by other processes (like VSCode):
- Start
VSCodeor other process that locks files in user'sLOCALAPPDATA\Tempfolder Remove-Item -Path "$env:LOCALAPPDATA\Temp\*" -Recurse -Force -ErrorAction Ignore -Verbose
This does not throw on PowerShell 7.4.2 or PowerShell 5.1
Possible cause
I guess this might have something to do with new progress bar for Remove-Item?
Workaround
The error is gone when I disable the progress bar with $ProgressPreference = 'SilentlyContinue'
Expected behavior
No error is thrownActual behavior
PS C:\> Remove-Item -Path "$env:LOCALAPPDATA\Temp\*" -Recurse -Force -ErrorAction Ignore
Remove-Item: Attempted to divide by zero.Error details
Exception :
Type : System.DivideByZeroException
TargetSite :
Name : RemoveDirectoryInfoItem
DeclaringType : [Microsoft.PowerShell.Commands.FileSystemProvider]
MemberType : Method
Module : System.Management.Automation.dll
Message : Attempted to divide by zero.
Source : System.Management.Automation
HResult : -2147352558
StackTrace :
at Microsoft.PowerShell.Commands.FileSystemProvider.RemoveDirectoryInfoItem(DirectoryInfo directory, Boolean recurse, Boolean force, Boolean rootOfRemoval) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\namespaces\FileSystemProvider.cs:line 3124
at Microsoft.PowerShell.Commands.FileSystemProvider.RemoveDirectoryInfoItem(DirectoryInfo directory, Boolean recurse, Boolean force, Boolean rootOfRemoval) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\namespaces\FileSystemProvider.cs:line 3073
at Microsoft.PowerShell.Commands.FileSystemProvider.RemoveDirectoryInfoItem(DirectoryInfo directory, Boolean recurse, Boolean force, Boolean rootOfRemoval) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\namespaces\FileSystemProvider.cs:line 3073
at Microsoft.PowerShell.Commands.FileSystemProvider.RemoveDirectoryInfoItem(DirectoryInfo directory, Boolean recurse, Boolean force, Boolean rootOfRemoval) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\namespaces\FileSystemProvider.cs:line 3073
at Microsoft.PowerShell.Commands.FileSystemProvider.RemoveItem(String path, Boolean recurse) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\namespaces\FileSystemProvider.cs:line 2904
at System.Management.Automation.SessionStateInternal.RemoveItem(CmdletProvider providerInstance, String path, Boolean recurse, CmdletProviderContext context) in
D:\DEVELOPMENT\PowerShellCore\src\System.Management.Automation\engine\SessionStateContainer.cs:line 1018
CategoryInfo : NotSpecified: (:) [Remove-Item], DivideByZeroException
FullyQualifiedErrorId : System.DivideByZeroException,Microsoft.PowerShell.Commands.RemoveItemCommand
InvocationInfo :
MyCommand : Remove-Item
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 1
Line : Remove-Item -Path "$env:LOCALAPPDATA\Temp\*" -Recurse -Force -ErrorAction Ignore
Statement : Remove-Item -Path "$env:LOCALAPPDATA\Temp\*" -Recurse -Force -ErrorAction Ignore
PositionMessage : At line:1 char:1
+ Remove-Item -Path "$env:LOCALAPPDATA\Temp\*" -Recurse -Force -ErrorA …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Remove-Item
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1Environment data
Name Value
---- -----
PSVersion 7.5.0-preview.3
PSEdition Core
GitCommitId 7.5.0-preview.3-20-gcdb7556d041b5db42049b39a9cf0363b5b9806a6
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
Badgerati, jazzdelightsme and mdaneri
Metadata
Metadata
Assignees
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

