As a followup to my previous question about editing an ini I've found now that I've got to add two lines of text to the final ini. The big caveat here is that I need this to work on Win7 with Power Shell 1.
My current Power Shell script is
(gc c:\temp\Bakemark\wmars.ini) -replace 'wmars', 'wmarsnet' | Out-File c:\temp\wmars.ini
I need to add 2 lines to the end of the file:
I tried add-content C:\temp\wmars.ini -Value "'n[DATABASE]" but it's throwing an error because of the brackets I believe. ParserError: (:) , ParentContainsErrorRecordException
PS is pretty outside of my normal stuff so I'm floundering a bit here.
I also tried add-content C:\temp\wmars.ini -Value "Database" add-content C:\temp\wmars.ini -Value "name-wmarsnet" but it adds a line in Chinese at the end of the ini.
I may have beaten my head against it enough to work.
add-content c:\temp\mars.ini -Value "[Database]" -Encoding Unicode
add-content c:\temp\mars.ini -Value "name=wmarsnet" -Encoding Unicode
Hi Trevor, Maybe try with single ( ' ' )quotes in your powershell. that has resolved some of my scripts (I couldnt tell you exactly why )
Alternative: use two CMD commands:
1) Echo [DATABASE] >>>> c:\temp\wmars.ini
2) Echo name=wmarsnet >>>> c:\temp\wmars.ini