Invoke-Obliteration

1.0.1

This function deletes one or more files or folders recursively, including its files and sub-directories.
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
This function deletes one or more files or folders recursively, including its files and sub-directories.
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 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'.

Show more

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Script -Name Invoke-Obliteration -RequiredVersion 1.0.1

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

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.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

Version History

Version Downloads Last updated
1.0.2 14 10/28/2024
1.0.1 (current version) 134 10/12/2024
1.0.0 6 10/11/2024