Other answers have the regex side covered well enough. Whenever I see little logs like this I always think about ConvertFrom-StringData
which
converts a string that contains one or more key and value pairs into a hash table.
From: help ConvertFrom-StringData
In its basic form we just do something like this:
$pairs = Get-Content -Raw -File $pathtofile | ConvertFrom-StringData
[pscustomobject]$pairs
Which would give you a PowerShell object that you can interact with easily!
DS : LOG_4|
Schema : LOLYY|
IDs : xxxxx,xxxx
Log : false|
DBMS : mssql|
Host : abc.XYz.com|
Phase : |
DaemonReruns : 2|
Doubtful that you need the trailing pipes. You can remove those with some regex or simpler string methods.
[pscustomobject](Get-Content -File $pathToFile | ForEach-Object{$_.trimend("|")} | Out-string | ConvertFrom-StringData)
[pscustomobject]((Get-Content -Raw -File $pathToFile) -replace "(?m)\|$" | ConvertFrom-StringData)
In any case this gives you more options as to how you need to deal with your data.