Reputation: 1278
I'm trying to programattically create a file using Powershell (I know, noob stuff) with multiple lines of content.
My attempt is as follows:
$ServicesYaml = @'
parameters:
twig.config:
debug: true
auto-reload: true
cache: false
'@
$ServicesYaml | Out-File -FilePath .\services.yml
This seems fine when printing to the console using Write-Output
:
But prints out extra lines when sending to a file: (Viewed using Atom):
What am I doing wrong? I obviously don't want all of the unprintable and extra whitespace that appears to be getting printed.
Upvotes: 1
Views: 163
Reputation: 3107
This is a clash of linuxy nature of GIT and Windows text file byte order mark. The Out-File commandlet uses a Windows encoding (USC-2 LE BOM) that GIT does not supports and GIT treats the file as binary instead of text. Try using Set-Content commandlet which uses UTF-8 without BOM
$ServicesYaml = '
parameters:
twig.config:
debug: true
auto-reload: true
cache: false
'
$ServicesYaml | Set-Content -FilePath .\services.yml
Upvotes: 2