Try this:
$ldiffile = 'c:\junk\x.ldf'
$destination = 'c:\junk\x.csv'
$omit = 'dn','objectclass','sn','vcardcategories'
$a = @{} # initialize the temporary hash
$x = @() # results
Get-Content $ldiffile |
ForEach-Object {
if ($_ -match "^\s*$") { # blank line - dump the hash and reinitialize the hash
$x += [PSCustomObject]$a
$a = @{ }
}
else { # add the not-omitted key/value to the hash
$key, $value = $_ -split ": "
if ($omit -notcontains $key){
$a[$key] = $value
}
}
}
if ($a.keys.length -gt 0){ # emit last LDIF entry if LDIF didn't end w/blank line
$x += [PSCustomObject]$a
}
$x | Export-Csv $destination -NoTypeInformation