Snippets

Ettar Powershell Dateien/Verzeichnisse in Unterverzeichnissen löschen

Created by Ettar
$path = Read-Host "Pfad"

if(!(Test-Path $path)){
    Write-Host "Pfad $path unbekannt"
}else{
    if((Read-Host "Unterverzeichnisse in $path bereinigen (J/N)?") -eq "J"){
        foreach($folder in (Get-ChildItem $path -Directory)){
            foreach($file in (Get-ChildItem $folder.FullName)) {
                Remove-Item $file.FullName
            }
        }
    }else{
        Write-Host "Skript wird abgebrochen"
    }
    
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.