I am looking for desired output as shown below. The main concept is to join the next line with current line and result into one line if it ends with a character.
Thank you
$file = 'textfile.txt'
$reportObject = @()
foreach ($line in $file) {
$content = [IO.File]::ReadAllLines($file)
for ($i = 0; $i -lt $content.count; $i++) {
$line = $content[$i]
if ($line.StartsWith("Users")) {
$a = 0
while ($content[$i + $a].EndsWith("\")) { #"
$reportObject += $content[$i + $a]
$a++
}
$reportObject += $content[$i + $a]
}
}
$reportObject
}