Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Add line to a text file just after a specific line with PowerShell

$
0
0

Hi,

I have to edit remotely a file called nsclient.ini on hundreds of computers, the file contains some command definitions. For example:

[/settings/external scripts/scripts]    
check_event="C:\Program Files\NSClient++\scripts\Eventlog.exe" -e System -t Error
check_event_application="C:\Program Files\NSClient++\scripts\Eventlog.exe" -e Application -t Error
check_activedir=cscript "C:\Program Files\NSClient++\scripts\Check_AD.vbs" //nologo

I need to add a new line just beneath [/settings/external scripts/scripts] This new line should not overwrite the existing lines beneath.

Thanks for your help.


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>