Prerequisites
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
VSCode or other process that locks files in user's LOCALAPPDATA\Temp folder
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
Actual 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 1
Environment 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.0
Visuals

Prerequisites
Steps to reproduce
Remove-ItemthrowsAttempted to divide by zeroon PS 7.5.0.preview.3 when removing items from folder where some of files are empty and locked by other processes (like VSCode):VSCodeor other process that locks files in user'sLOCALAPPDATA\TempfolderRemove-Item -Path "$env:LOCALAPPDATA\Temp\*" -Recurse -Force -ErrorAction Ignore -VerboseThis 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
Error details
Environment data
Visuals