remove more than one folder

Welcome Forums General PowerShell Q&A remove more than one folder

Viewing 2 reply threads
  • Author
    Posts
    • #263600
      Participant
      Topics: 1
      Replies: 0
      Points: 12
      Rank: Member

      hi, I am having trouble in removing more than a folder, I tried:

      but I got the error:

      • This topic was modified 3 months, 1 week ago by cimerio84.
      • This topic was modified 3 months, 1 week ago by cimerio84.
      • This topic was modified 3 months, 1 week ago by grokkit.
    • #263669
      Senior Moderator
      Topics: 10
      Replies: 205
      Points: 1,117
      Helping Hand
      Rank: Community Hero

      Remove-Item only accepts one path at a time.

      If you want to remove everything stored in tempS9 you can use a wildcard like this:

      but be careful because this will remove everything in that directory.

      If you need to remove specific items in that directory then the easiest thing to do is store the names of the things you want to remove in an array and then use a foreach loop to apply Remove-Item to each one.

      Also, if your file path actually has a # symbol in it as shown in your command then you will need to wrap the path in quotes like this:

      It’s generally safer to wrap paths in quotes to ensure that they are interpreted correctly.

    • #263690
      Participant
      Topics: 5
      Replies: 349
      Points: 632
      Helping Hand
      Rank: Major Contributor
Viewing 2 reply threads
  • The topic ‘remove more than one folder’ is closed to new replies.