Private/Get-SpecLeafName.ps1
function Get-SpecLeafName { <# .SYNOPSIS This function extracts and returns the leaf name (filename with extension) from a given path. .DESCRIPTION The Get-SpecLeafName function takes a path as input and extracts the leaf name (filename with extension) from that path. .PARAMETER Path Specifies the path from which the leaf name will be extracted. .EXAMPLE Get-SpecLeafName -Path "C:\Files\Document.txt" Returns: "Document.txt" Extracts and returns the leaf name "Document.txt" from the given path "C:\Files\Document.txt". .EXAMPLE Get-SpecLeafName -Path "D:\Images\Pictures\holiday.jpg" Returns: "holiday.jpg" Extracts and returns the leaf name "vacation.jpg" from the given path "D:\Images\Pictures\holiday.jpg". .NOTES Author: owen.heaume Date: August 10, 2023 Version: 1.0 #> [cmdletbinding()] param ( [string]$Path ) $LeafName = [System.IO.Path]::GetFileName($Path) return $LeafName } |