Find folder and delete all sub folders and content

Welcome Forums General PowerShell Q&A Find folder and delete all sub folders and content

This topic contains 2 replies, has 2 voices, and was last updated by

Jim
 
Participant
1 year, 6 months ago.

  • Author
    Posts
  • #78325
    Jim

    Participant
    Points: 0
    Rank: Member

    Hello – I have a powershell script that will delete all folders and subfolders named IE and it's contents but I want to add some logging.

    I launch Powershell change the the root of the directory and then I run the below command line.
    get-childitem .\IE *.* -recurse -Hidden | Remove-Item -Force -Confirm

    I would like to output the results of the script to a csv file.

    Thanks in advance for any assistance.

  • #78334

    Keymaster
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Because Remove-Item lacks a -PassThru switch, you can't do this with a one-liner.

    You could put Tee-Object between them, if you don't need a CSV specifically?

    • #78343
      Jim

      Participant
      Points: 0
      Rank: Member

      That worked. Thank you!

The topic ‘Find folder and delete all sub folders and content’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort