locked
syntax to find all folders with *temp* in the name but exclude folders and files with *template* in the name RRS feed

  • Question

  • I'm trying to find all temp folders on my system without having files and folders with the word template included in my list.  I'm not sure how to get just "*temp*" without also getting "*templat*".

    My original statement was:

    get-childitem -recurse -ErrorAction ignore | where fullname -like "*temp*" | select -ExpandProperty fullName |
     fl |

     Any advice on how I can get my results to just display files and folders with the word "temp" anywhere in the fullname without also including files and folders that have the string "templat" in the full name?
    Friday, August 11, 2017 7:52 PM

All replies

  • get-childitem -recurse -ErrorAction  0 -Include *temp* | Where{$_.Name -notlike '*template*'}


    \_(ツ)_/

    • Proposed as answer by seanmcavinue Saturday, August 12, 2017 8:41 AM
    Friday, August 11, 2017 7:59 PM
  • Hi,
    Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance.

    Best Regards,

    Frank

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, September 6, 2017 7:47 AM