I'm having trouble adding a new line into a string in powershell:
Get-ChildItem "C:\Users\matt\Desktop\CShell Install" |foreach {'<Component Id="'+$_.name+'" Guid="' +[guid]::NewGuid() + '">`r`n<File Id="'+$_.name+'" Source="$(var.CShell.TargetPath)"></File></Component>'}
As you can see I want a newline to occur at
``r`n
instead they are printed literally.
Any pointers?
Do not use Single Quote, where you want PowerShell to honor backticks (or any other characters that you need PowerShell to interpret).
"FirstLine`r`nSecondLine" prints
FirstLine
SecondLine
'"FirstLine`r`nSecondLine"' prints
"FirstLine`r`nSecondLine"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With