Hidden folders RRS feed

  • Question

  • Hello,

    Im running the following script to delete files and folders in a directory and its subdirectories and keep the folder structure.
    Right now everything works fine but hidden folders are not deleted ($RECYCLE.BIN)

    This is the script: Get-ChildItem -Path D:\path\to\data -Include * -File -Recurse | foreach { $_.Delete()}

    So all the data, from the subfolders in D:\path\to\data are deleted except the hidden one.
    Can someone help?



    Monday, May 13, 2019 2:39 PM


  • Try adding "-Force" to the Get-ChildItem.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    • Proposed as answer by jrv Monday, May 13, 2019 3:13 PM
    • Marked as answer by LEVDLEVD Tuesday, May 14, 2019 6:55 AM
    Monday, May 13, 2019 3:02 PM

All replies