I have two different text file having different harder for example as below
Example1.txt having header WebAppName, Version,state,UserIdentityType,Username,Password
Example2.txt having Name,state,application
So I need to concatenating both output into signal text file on Example1.txt using powershell.
Anyone provide solution also I try GC Example1.txt, Example2.txt | add-content Example1.txt But I don't get results as expected due to different harder.
As you only want to concatenate the two files you can simply get their contents and loop over all the lines and concatenate them into a new line:
$example1 = Get-Content .Example1.ps1;
$example2 = Get-Content .\Example2.ps1
$output = [System.Text.StringBuilder]::new();
for($c = 0; $c -lt $example1.Count; $c++)
{
$null = $output.Append($example1[$c]);
$null = $output.Append(',');
$null = $output.AppendLine($example2[$c]);
}
$sb.ToString() | Out-File .\Output.txt
You certainly have to make sure, that both files have the same number of lines.