Private/Get-FileHashtable.ps1

function Get-FileHashtable {
    <#
.SYNOPSIS
    This function creates a hashtable representing the files in a given directory.
.DESCRIPTION
    The Get-FileHashtable function takes a path as input and creates a hashtable where each entry represents a file in the directory. The keys in the hashtable are created by concatenating the parent folder name, the filename without the extension, and the extension, with underscores in between. Any invalid characters in the key are replaced with underscores. The values in the hashtable are the full paths of the files.
.PARAMETER Path
    The path of the directory to get the files from. This parameter is mandatory.
.EXAMPLE
    $fileHashtable = Get-FileHashtable -Path "C:\Users\Username\Documents\SomeFolder"
    This example creates a hashtable of the files in the "SomeFolder" directory.
.EXAMPLE
    $filePath = $fileHashtable["SomeFolder_SomeFile_txt"]
    This example shows how to access a file path in the hashtable using a key.
#>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true, Position = 0, HelpMessage = "The path of the directory to get the files from.")]
        [string]$Path
    )
    begin {
        Write-Debug -Message "Begin '$($MyInvocation.MyCommand.Name)' at '$(Get-Date)'"
        Write-Verbose -Message "Test '$($Path)'"
        if (!(Test-Path -Path $Path)) {
            throw "The path '$Path' does not exist."
        } else {
            Write-Verbose -Message "'$($Path)' exists, processing"
        }
        $result = @{}
    }
    process {
        try {
            Write-Information -Message "Get all files in '$($Path)' and add to result hashtable"
            $files = Get-ChildItem -Path $Path -File
            foreach ($file in $files) {
                Write-Verbose -Message "Add '$($file.FullName)' to the hashtable with the '$($file.Name)' as the key"
                $result[$file.Name] = $file.FullName
            }
            Write-Output $result
        }
        catch {
            if ($_.Exception -and $_.Exception.Message) {
                Write-Error "An error occurred: $($_.Exception.Message)"
            } else {
                Write-Error "An error occurred, but no additional information is available."
            }
        }
    }
    end {
        if ($?) {
            Write-Debug -Message "End '$($MyInvocation.MyCommand.Name)' at '$(Get-Date)'"
        }
    }
}