param ( [string]$Path, [string[]]$Include ) function Get-IncludedTree { param ( [string]$Directory, [string[]]$Include, [int]$Indent = 0 ) # Check if the current directory should be included $includeCurrent = $false foreach ($include in $Include) { if ($Directory -like "*\$include*") { $includeCurrent = $true break } } if ($includeCurrent) { # Output the current directory with indentation Write-Host (" " * $Indent) + "+---" + (Split-Path -Leaf $Directory) # Process subdirectories and files Get-ChildItem -Path $Directory | ForEach-Object { if ($_.PSIsContainer) { Get-IncludedTree -Directory $_.FullName -Include $Include -Indent ($Indent + 4) } else { Write-Host (" " * ($Indent + 4)) + "+---" + $_.Name } } } } # Start processing from the given path Write-Host "Starting at path: $Path" Get-ChildItem -Path $Path -Directory | ForEach-Object { Get-IncludedTree -Directory $_.FullName -Include $Include } Write-Host "Processing completed."