Files without an extension deletion RRS feed

  • Question

  • Hello,

    Below script is for recursive deletion of all files (not folders) older than 30 days except for some extension to be excluded.

    the script works but I notice it doesn't delete files which don't have an extension (I mean some files shows as File in proprieties)

    Get-ChildItem -path "C:\TEST\" -exclude *.log,*.hep,*.sep,*.ocs,*.xls,*.xlsx,*.doc,*.pdf,*.ps1,*.dll,*.mdb,*.exe,*.inf,*.ini,*.jpg,*.bmp,*.gif,*.jpeg,*.png -recurse -file -erroraction silentlycontinue | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} | tee -FilePath "C:\Scripts\Logs\Deleted Files-$logtime.log" -Append | ForEach-Object { sdelete -P 1 -R -S $_.FullName }

    Could you please advise how to delete files without an extension?

    Thanks in advance

    Sunday, January 28, 2018 7:11 AM