Powershell Split Text into Individual Lines
Inline
$list = @"
server1
server2
server3
server4
server5
server6
server7
"@
$regex = '[\r\n]{1,}'
$new = $list -split $regex
$new | measure
Count : 7
External File
$list = Get-Content list.txt
$new | measure
Count : 7
Related
- PowerShell Accepting Pipeline Input
- Install PowerShell Core on Raspberry Pi OS
- Moving AD Computer Object with Powershell
- Rounding Numbers in PowerShell
- Extend Volume in Windows
- Install RSAT on Windows
- Enable Telnet Client on Windows
- Hashing in Windows
Links
- https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_regular_expressions?view=powershell-7.1