$sourceFilePath = "C:\path\to\your\largefile.txt" $outputDirectory = "C:\path\to\output" $linesPerFile = 1800 # Number of lines per chunk # Read the file and split it into chunks $fileContent = Get-Content $sourceFilePath $totalLines = $fileContent.Count $numberOfFiles = [math]::Ceiling($totalLines / $linesPerFile) for ($i = 0; $i -lt $numberOfFiles; $i++) { $startLine = $i * $linesPerFile $endLine = $startLine + $linesPerFile - 1 if ($endLine -ge $totalLines) { $endLine = $totalLines - 1 } $fileContent[$startLine..$endLine] | Set-Content (Join-Path $outputDirectory ("Chunk_" + $i + ".txt")) }