Add lines in  a section in INI file in powershell

A simple example - 

$content = @()
gc C:\<yourfile>.ini | % {

if($_ -eq "[Microsoft Visio Viewer 2013.dat]"){

$content += $_ + "`nNew Line"

}else{

$content += $_

}}
$content


  • Edited by Braham20 23 hours 42 minutes ago
June 25th, 2015 3:28am

Here are the INI file edit commands that are built into WIndows:

https://gallery.technet.microsoft.com/Edit-old-fashioned-INI-f8fbc067

Read instructions carefully.

Free Windows Admin Tool Kit Click here and download it now
June 25th, 2015 4:07am

Hello,

I am trying to automate a task using powershell. But one of the modules of the script brings the INI into a proper format. So i have a section called
[Microsoft Visio Viewer 2013.dat]
Source=%ProgramFilesDir%\Internet Explorer\iexplore.exe
;Change ReadOnlyData to bin\Package.ro.tvr to build with old versions(4.6.0 or earlier) of tools
ReadOnlyData=Package.ro.tvr
Disabled=1
MetaDataContainerOnly=1

I wish to add a line just below the [Microsoft Visio Viewer 2013.dat] line. There are more or less similar sections as above and i need to achieve same task for them as well. How can this be done ?


June 25th, 2015 7:07am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics