Split Large Text File using PowerShell


You need to view a large log file (2GB+) and circumstances won’t allow you to download tools online (i.e. security policies). The usual file editors such as Notepad and Notepad++ couldn’t open the file as it’s too big.

You can use an online tool but this makes searching for specific terms unusable.

One way around this is to use PowerShell:

$i=0; Get-Content C:\logs\sample.log -ReadCount 100000 | %{$i++; $_ | Out-File -filepath C:\logs\output\out_$i}