Filtirening subfolders based on fullpath

i need a script that it displays in csv file specific subfolders based on specific word in full path. i used the next script, but he does not works

Get-ChildItem -Recurse -Force -ErrorAction SilentlyContinue | Where { $.PSisContainer } |
Where-object{$
.Name -like “PotpisVDR” -and $_.FullName -like “2023”} | Select-object FullName | export-csv path.csv

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

When you use the comparison operator -like you have to add wildcards in front, at the end or around your search pattern depending on what you’re looking for exactly. Otherwise it works like an -eq comparison.
Here some working examples:

'random2023' -like '*2023'
'random2023ranmdom' -like '*2023*'
'2023random' -like '2023*'

If you remove any of the * all these comparisons evaluate to $false. :wink:

Without wildcard it works like an -eq

'2023' -like '2023'
1 Like