Powershell newbie here. Working on an automation task where I’m only allowed to use powershell since it’s a tightly controlled microsoft environment. And even in that I’m limited to using Powershell 4. I’m aware that the answer is quite simple in powershell5 but I don’t have that luxury.
I have a csv file with top 5 and bottom 5 rows that aren’t desired since they are not part of the data. My code is -
Import-Csv C:\Data\XFC.csv -Header "Date", "Received", "Answered", "Answer time", "Transferred", "Agency", "Answered (S)", "Answer time (S)", "Disconnected", "Total call time"| select-object -Skip 5 -last| Export-csv C:\Data\XFC_processed.csv -NoTypeInformation
I get the following error -
Select-Object : Missing an argument for parameter 'Last'. Specify a parameter of type 'System.Int32' and try again.
I understand the error but I just can’t figure out the correct syntax from microsoft documentation.
I know how to skip the first 5 rows but I’m looking for a simplistic one line solution for skipping the bottom few rows as well. There is a blank row before the bottom 5 rows (which show the summary stats for the dataset) but the actual dataset itself doesn’t have any blank rows as the data is autogenerated data from call logs. So another solution to this could be ignoring everything that comes after that blank row.
Appreciate your help. Thank you.