Functions/FileSystem/Get-ItemMetaData.ps1

function Get-ItemMetaData
{
    [CmdletBinding()]
    Param()
    DynamicParam
    {
        # Get Current Folder Metadata
        $MetaDataMap = $Global:PS_Media_MetaDataMap

        # Instantiate Runtime Parameter Dictionary, Attach Runtime Parameters, and return
        $RuntimeParameterDictionary = [System.Management.Automation.RuntimeDefinedParameterDictionary]::new()
        $RuntimeParameterDictionary.Add('Path', (New-StaticParameter -ParamName 'Path' -ValueType string[] -Mandatory $true -ValueFromPipeLine $true))
        $RuntimeParameterDictionary.Add('ExcludeEmptyProperties', (New-StaticParameter -ParamName 'ExcludeEmptyProperties' -ValueType bool -Mandatory $false -DefaultValue $false))
        $RuntimeParameterDictionary.Add('Properties', (New-DynamicParameter -ParamName 'Properties' -ValueType string[] -Dataset @($MetaDataMap.Keys+"*") -Mandatory $false -DefaultValue "*"))
        return $RuntimeParameterDictionary
    }
    Begin
    {
        # Convert Runtime Parameter Dictionary into Available Constants
        Initialize-DynamicParameters -DynamicDictionary $RuntimeParameterDictionary

        $oShell = New-Object -ComObject Shell.Application
        if($Properties -contains '*'){$Properties = [array]($MetaDataMap.keys)}
    }
    Process
    {
        
        Foreach ($sPath in $Path)
        {
            $PathTest = Test-Path -Path $sPath -PathType Leaf
            if($PathTest)
            {
                # Get Item
                $FileItem = Get-Item -Path $sPath
                
                # Get Folder and Item Data using the Instantiated Shell Application
                $oFolder = $oShell.Namespace($FileItem.DirectoryName)
                $oItem = $oFolder.ParseName($FileItem.Name)

                # Build an array of the file properties
                $FilePropHash = [ordered]@{}
                Foreach ($Property in $Properties)
                {
                    $PropNums = [array]($MetaDataMap.$Property)
                    $PropVals = Foreach ($Propnum in $PropNums)
                    {
                        $Detail = $oFolder.GetDetailsOf($oItem, $PropNum)
                        if(($Detail -notlike "") -or ($ExcludeEmptyProperties -eq $false)){$Detail}
                    }
                    if(($PropVals -notlike "") -or ($ExcludeEmptyProperties -eq $false)){$FilePropHash.Add($Property,$PropVals)}
                } 

                $FileObject = [PSCustomObject]($FilePropHash)
                $FileObject
            }
        }
    }
    End {$oShell = $null}
}