Powershell -split ('') indicates a new line

Get-Content $user| Foreach-Object{
   $user = $_.Split('=')
   New-Variable -Name $user[0] -Value $user[1]}

I am trying to work with a script and split a text file into an array, breaking a file based on each new line

What should I change the = sign to

+4
source share
1 answer

It depends on the exact encoding of the text file, but [Environment]::NewLineusually does the trick.

"This is `r`na string.".Split([Environment]::NewLine)

Conclusion:

it

line.

+13
source

Source: https://habr.com/ru/post/1653060/


All Articles