Functions/FileSystem/Get-TextFileTree.ps1
Function Get-TextFileTree { [CmdletBinding()] Param () DynamicParam { # 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)) return $RuntimeParameterDictionary } Begin { # Convert Runtime Parameter Dictionary into Available Constants foreach ($key in $RuntimeParameterDictionary.keys) {New-Variable -Name $key -Value $RuntimeParameterDictionary.$key.value} # Get Filetree from target path Import-FileExtensions $Files = [array](Get-Childitem -Path $Path -Recurse -File | where Extension -in $Global:PS_TextExtensions) } Process { $FileTree = Foreach ($File in $Files) { Write-Progress -Activity "Getting Blob, Hash, and Encoding from Text Files" -CurrentOperation "[$I/$($Files.count)] File: $($File.Name)" -PercentComplete ($I/$Files.count*100) [pscustomobject]([ordered]@{ Name = $File.Name FullName = $File.FullName Extension = $File.Extension Chain = ($File.FullName.replace("$Path","$($Path | split-path -Leaf)")) Base64 = ($File | get-content -raw | Convert-StringToBase64) MD5 = ($File | Get-FileHash -Algorithm MD5).Hash Encoding = ($File | Get-FileEncoding).EncodingPS }) $I++ } $FileTree } } |