Private/Storage/FlatFile/Get-PukFlatFileStore.ps1
|
function Get-PukFlatFileStore { [CmdletBinding()] [OutputType([psobject])] param( [Parameter(Mandatory)] [string]$Path, [Parameter(Mandatory)] [System.Security.Cryptography.X509Certificates.X509Certificate2]$Certificate ) if (-not (Test-Path -LiteralPath $Path)) { return [PSCustomObject]@{ schemaVersion = '1.0' hostingModel = 'FlatFile' records = @() } } $encrypted = Get-Content -LiteralPath $Path -Raw -ErrorAction Stop $store = Unprotect-PukFlatFileData -Content $encrypted -Certificate $Certificate if (-not $store.records) { $store | Add-Member -MemberType NoteProperty -Name 'records' -Value @() -Force } return $store } |