Fastest way to delete folder that has complex structure

38 Views Asked by At

I need more fast way to delete complex folder structure.

I have tried this one, can you improve that?

Function Fast-Delete {
    Param(
        [Parameter(Valuefrompipeline=$True, Mandatory=$True)] [String]$Directory
    )
 
    $emptyDir = GetRandomTempPath
    mkdir $emptyDir

    robocopy $emptyDir $Directory /mir /NFL /NDL /NJH /NJS /nc /ns /np /log:$env:TEMP/fatih_fast_delete_log.txt /mt:16

    Remove-Item -Path $Directory -erroraction silentlycontinue
    Remove-Item -Path $emptyDir -erroraction silentlycontinue
}
0

There are 0 best solutions below