This is a somewhat naive parser for the data provided:
$InFile = "c:\junk\parse.txt"
$rule = [ordered]@{}
$incmdlet = $false
$lines = Get-Content $InFile
ForEach ($ln in $lines){
if ($ln.Trim().Length -eq 0){
if ($incmdlet){
[PSCustomObject]$rule
}
$rule = [ordered]@{}
$incmdlet = $false
continue
}
if ($ln -like "Add-ADSyncAttributeFlowMapping*"){
$incmdlet = $true
continue
}
if ($incmdlet -and $ln.substring(0,1) -eq '-'){ # a parameter and value or a switch with a value
if ($ln -match "^-(\w+?)\s+:?([^``]+)") {
$rule[$matches[1]] = $matches[2].Trim().Trim("'")
}
elseif ($ln -match "^-(\w+?)\s+``?)") { # a switch with no value
$rule[$matches[1]] = ""
}
}
}
Note: in its present form, the code depends on an empty line at the end of the file to produce the PSCustomObject. Also, if there are parameter names that are not present in all the cmdlets you may have to provide a "-Header" parameter to any Export-CSV because the objects don't contain a uniform set of parameter names.