how to split a csv file into small chunks with headers using powershell

I am using the following code to split the large csv file into chunks. But the headers are not appending output files. Here is the powershell script: $InputFilename = Get-Content ‘C:\Users\Sridhar\Downloads\Leads.csv’ $destinationPath = ‘C:\Users\Sridhar\Downloads\’ $OutputfilenamePattern = ‘leads_’ $LineLimit = 500 $line = 0 $i = 0 $file = 0 $start = 0 $header = $InputFilename[0]… Read More how to split a csv file into small chunks with headers using powershell

In Powershell, how to wait for parallel jobs to finish before proceeding?

Based on How to execute a PowerShell function several times in parallel?, I’m able to do this, where I stop all running jobs, in parallel. # Run this in parallel $stopService { param($service) Stop-Service -Name $service.name -Force } $services = Get-Services | Where-Oject {$_.name -like "*XYX_*"} Foreach($service in Sservices) { Start-Job -ScriptBlock $stopService -ArgumentList $service… Read More In Powershell, how to wait for parallel jobs to finish before proceeding?