Link to home
Start Free TrialLog in
Avatar of SvenIA
SvenIAFlag for Netherlands

asked on

Powershell add text to a specific line in txt file

Hi!

I have a text file. I need to add some text at line 10 of this file. Line 10 is empty, so 'replace' is not an option.

Can it be done using powershell?
ASKER CERTIFIED SOLUTION
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SvenIA

ASKER

Thanks, but with this code i cannot add text on an empty line, only overwrite the text on the previous line.

Array assignment failed because index '10' was out of range.
Avatar of SvenIA

ASKER

It does seem to work now. Don't know why it didn't just before. Thanks a lot!