Invoke-Obliteration

1.0.0

This function deletes one or more directories recursively, including its files and sub-directories.
If one of the file system objects are open in another process it attempts to close the handles.
It was designed to be fast, so we had to use partially undocumented Windows APIs and .NET asynchronous primitives.
For this reason all logic, except the monitoring, was writt
This function deletes one or more directories recursively, including its files and sub-directories.
If one of the file system objects are open in another process it attempts to close the handles.
It was designed to be fast, so we had to use partially undocumented Windows APIs and .NET asynchronous primitives.
For this reason all logic, except the monitoring, was written in C#. That's why the huge signature.
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, simple, fast, and deadly.
Closing other processe's handles to a file system object may cause system malfunction. Use it with care!

About privileges:
This function requires to be ran as administrator, because it needs access to delete files potentially in protected places.
The main API enables 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.0

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.

FileList

Version History

Version Downloads Last updated
1.0.1 104 10/12/2024
1.0.0 (current version) 6 10/11/2024