Now I have two text files – which I don’t have the option of merging as one file. So I’ll need to programmatically concatenate the files by some adjustments to the existing code.

How can introduce the second file , but not make many adjustments to the existing Powershell script?

Answer: There are a number of methods to concatenate to text files dynamically. I’ll offer one method based on the code snippet presented . On the assumption – it will cause minimal disruption.

An adjustment you could make is to extend the get-content cmdlet . So instead of referencing one variable , which you’ve added one file, you could reference two variables, which would reference two files.

In the example below, I've a) added a new variable $serverpathextra b) referenced the new variable through get-content