After doing numerous online searches I have yet to find a way to do this. There are really two parts to my question:
How do you add a new stanza between two existing ones?
If I have the following stanzas in an existing file:
[Section 1] Host=A IP=10.10.10.1 [Section 2] Host=B IP=10.10.10.2
How can I use Powershell to add:
[Section 3] Host=C IP=10.10.10.3
between Section 1 and Section 2 to achieve:
[Section 1] Host=A IP=10.10.10.1 [Section 3] Host=C IP=10.10.10.3 [Section 2] Host=B IP=10.10.10.2
How do I add a new stanza after the last comment line of an existing file?
For example if I have:
# # Last change 1/1/2021 # [Profile sql] Profile=HR
How would I add:
[Profile postgres] Profile=Exec
to achieve:
# # Last change 1/1/2021 # [Profile postgres] Profile=Exec [Profile sql] Profile=HR
in Powershell?