Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Path = "C:\Windows\System32\config\systemprofile\AppData\Local"
- #(gci $Path -r -force | ? {$_.PSIsContainer -eq $True}) | ?{$_.GetFileSystemInfos().Count -eq 0}
- (gci $Path -r -force | ? {$_.PSIsContainer -eq $True}) | ?{$_.GetFileSystemInfos().Count -eq 0} | remove-item
- Powershell ISE als Admin ausführen, reinkopieren. Das Skript löscht nur leere Ordner.
- Alternativ:
- $FileList = Get-ChildItem C:\Windows\System32\config\systemprofile\AppData\Local\ -Include tw-* -Recurse -force
- foreach ($File in $FileList)
- {
- Write-Output $File.FullName
- Try
- {
- #Remove-Item $File.FullName -Force -ErrorAction Stop
- Remove-Item $File.FullName -Force -ErrorAction Stop -WhatIf
- Write-Output "Deleted: $($File.Parent)\$($File.Name)"
- }
- Catch
- {
- Write-Output "Error deleting: $($File.Parent)\$($File.Name); Error Message: $($_.Exception.Message)"
- }
- }
- Zum wirklichen löschen, bitte # bei -Whatif hinzufügen und # bei dem darüberliegenden Befehl entfernen.
- # entspricht REM in Batch Dateien.
Advertisement
Add Comment
Please, Sign In to add comment