I'm super new to powershell.
What I want to achieve is this:
If I write this statement directly into the Code for example:
$SQL_output =" select *
Then it works correctly and it replaces the new line.
Anyone can help?
Get-Content splits lines on line feeds as is and creates an array of strings, one line per item. In order to disable the splitting to get the behaviour you want, you will need to add the -Raw parameter. 🙂
Thanks for the help, works now!
At first it still didn't work, but I just noticed that I had to add "`r" to the RegExpr. 😀
Ah, yeah, that'd probably do it. I shoulda noticed that!
This can vary depending on OS and what some editors will use, though, so be careful!
If you need to split on any of multiple types of newline sequences, you can do a regex split using the various kinds:
$String -split "`r`n|`n|`n`r"
(pipe in regex is an 'or')
You must be logged in to reply to this topic.