Try this:
$ldiffile = 'c:\junk\xx.ldf'
$destination = 'c:\junk\xx.csv'
$regex1 = 'CN=(.*?(?<!\\)),(.*)'
$regex2 = 'UID=(.*?(?<!\\)),(.*)'
$gname = ""
Get-Content $ldiffile |
ForEach-Object {
[array]$p = $_ -split ": ", 2
if ($p[0] -eq 'dn'){
$gname = $p[1] -replace $regex1,'$1'
}
elseif($p[0] -eq 'uniquemember'){
[PSCustomObject]@{
UID = $p[1] -replace $regex2,'$1'
GNAME = $gname
}
}
} | Export-Csv $destination -NoTypeInformation