Remove-Folder – how to remove only specific folders in a certain directory

//Remove-Folder – how to remove only specific folders in a certain directory
Remove-Folder – how to remove only specific folders in a certain directory 2017-08-09T16:42:54+00:00

The Toolkit Forums General Remove-Folder – how to remove only specific folders in a certain directory

  • Author
    Posts
  • Alex
    Participant
    Post count: 4
    #2227 |

    I am trying to create my pre-uninstallion requirements where I need to only delete certain folders that begin with “ABC.” in a specific directory, and not delete all folders in the directory. How can I achieve this properly since I see there is no wildcard parameter?
    Will a Remove-Folder -Path "<path-to-folder>\ABC.*" work?

  • Jim
    Participant
    Post count: 43

    I would just do something like this:

    $ABC = Get-ChildItem -Path "<path-to-folder>\ABC*" | Where-Object {$_.PSIsContainer}
    foreach ($_ in $ABC) {
    Remove-Folder -Path $_.FullName
    }

    I have yet to be successful posting code on here, hopefully this works…

You must be logged in to reply to this topic.