Reputation: 13
My script is used to find all subfolders with criteria like name matching under the root folder:
$Allsubfolders= gci c:\Root -recurse | Group-Object directoryname | select name
foreach ($folder in $Allsubfolders) {
if (($folder.name) -like "*NY*"){
$list = @(
@{source = "$($folder.name)"; dest=c:\dest}
)
}
The problem I have with my script is that I cannot grep all folders matching NY, I can only grep one of them. It seems like it stop on the first occurrence. How can I resolve this?
Upvotes: 1
Views: 1036
Reputation: 2152
Can you do something list this?
$Allsubfolders = Get-ChildItem -Recurse | Select-String -Pattern 'NY'
Upvotes: 1