cteneyck cteneyck - 1 year ago 142
PowerShell Question

powershell -split('') specify a new line

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

Im trying to work on a script and have it split a text file into an array, splitting the file based on each new line

What should I change the "=" sign to

Answer Source

It depends on the exact encoding of the textfile, but [Environment]::NewLine usually does the trick.

split on newline