<# FPS:Containers:Common:Public:Get-DirTree:ACTIVE
#>
function Get-DirTree() {
<#
.DESCRIPTION
Container Module: Common
Public CmdLet: Get-DirTree
Dependencies: None
CmdLet that returns the directory tree for the
path sent. An important detail is that the root is removed from the return list
so if the
fullname is required if should be prepended upon
use. Also, the return is an array, so the .replace function works as expected and will
not yeild an error. The
-Include parameter is just a convenience if you want to filter the items for
deletion purposes.
.USAGE
Called throughout FPS to determine a CmdLet's
existence. Returns a boolean
value
.EXAMPLE
if (Push-NeededFor "Get-DirTree")) {. (Get-ActiveFileNm
-PS1 Get-DirTree) }
$fileSet = Get-DirTree $global:pro_CIBase.RuntimeWeb
-FullPath
foreach ($file in $fileSet) { if ($file -like "*.jpg") { Write-Host ($file) }
}
Expected Result: Every fully qualified filename in the
path will be printed that are jpgs.
.CC
[2024.09.25 JD] Original code release
.NOTES
#>
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$true)] [string]$pPath,
[Parameter(Position=1, Mandatory=$false)] [switch]$Fullpath
)
$mbrs = Get-ChildItem $pPath -Recurse -Force
foreach ($mbr in $mbrs) {
$indMbr = $mbr.fullname
if ($PSBoundParameters.Fullpath -ne $true) { $indMbr = $indMbr.replace($pPath,"") }
if ($mbrSet -eq "") {
$mbrSet = $indMbr
} else {
@($mbrSet
$indMbr)
}
}
$mbrSet
}