Invoke-Obliteration
1.0.2
It was also designed to accept input from the pipeline, from Cmdlets like 'Get-ChildItem'.
If one of the file system objects are open in another process it attempts to close the handles.
The closing handle mechanism was ported from the 'WindowsUtils' module.
ATTEN
It was also designed to accept input from the pipeline, from Cmdlets like 'Get-ChildItem'.
If one of the file system objects are open in another process it attempts to close the handles.
The closing handle mechanism was ported from the 'WindowsUtils' module.
ATTENTION!!!
This function deletes files and potentially closes open handles without prompting for confirmation!
It was designed to be like that.
Closing other processe's handles to a file system object may cause system malfunction. Use it with care!
About privileges:
The main API tries to enable the 'SeBackupPrivilege' and 'SeRestorePrivilege' for the executing process token during execution to make sure we have the right permissions.
These privileges are disabled once the method ends.
About concurrent tasks:
This script deletes files and folders in parallel. You can set the maximum number of concurrent tasks by using the 'MaxConcurrentTask' parameter.
It's worth noting that there's a point where the bottleneck is on how fast the Operating System can open and close file handles, and not the capacity of the computer
of running the tasks, and this number is not big. 1000 concurrent tasks is plenty enough to saturate I/O without frying the CPU. You can play with this parameter to test
the limits of your system. MaxConcurrentTask = 0 means no limit.
About cancellation:
The main API implements a cancellation handler to capture 'Ctrl-C' and 'Ctrl-Break' commands.
All the internal APIs were designed with cooperative multitasking in mind, so if you press a cancellation combination the operation stops.
Due some bugs I found with Windows PowerShell I couldn't remove the handler at the end of execution because it breaks the console.
Although the handle continues registered it does nothing if it's not in the method execution 'context'.
Installation Options
Owners
Package Details
Author(s)
- francisconabas@outlook.com
Tags
Remove Delete Files Folders PowerShell Microsoft Windows Explorer
Dependencies
This script has no dependencies.
Release Notes
Version 1.0.2:
- Added remaining file count to the progress bar.
- Added average speed in files/s on the progress bar.
- Added the cancellation token to the progress object.
- Added check for cancellation on the PowerShell monitoring loop.
- Added parameter 'MaxConcurrentTask'.
- Various performance enhancements.
- Replaced the delete functionality with NT functions.
- Removed the threshold for parallel delete.
- Added parallel delete for remaining folders.
- Removed 'RaiseObjectHandleClosed' unnecessary multiple allocations.
- Cancellation handler not working for big number of files. Converted to native and created a scoped handler.
- Added task state check while waiting for the API to fill the total count, in case it fails so we don't keep stuck in the loop.
- Removed alias.
Version 1.0.1:
- Native array enumeration optimization.
- Consolidated folder and file delete in single method.
- Fixed bug on progress data.
- Fixed bug on closed handle warning.
- New monitoring mechanism.
- Changes on the C# code to conform to C# 5, because Windows PowerShell thinks it's 2012.
Version 1.0.0:
- Initial version published.
FileList
- Invoke-Obliteration.nuspec
- Invoke-Obliteration.ps1
Version History
Version | Downloads | Last updated |
---|---|---|
1.0.2 (current version) | 14 | 10/28/2024 |
1.0.1 | 134 | 10/12/2024 |
1.0.0 | 6 | 10/11/2024 |