Unique, incrementing, sequence number in CSV Header

Hi guys,

New to the forum (and to Powershell if I’m honest)

I have a problem I’m hoping someone can point me in the right direction to solve - I have to merge two CSV files, adding a header and trailer (which is fine), the resulting output CSV (named with date/time stamp) will then be sent to a supplier.

This will be a daily task and as such the suppliers format specifies that a unique file transaction/sequence number is included in the header - basically 1 for the first file and so on. For the life of me I can’t find out how to do this, referencing the previous sequence number and incrementing daily.

Any tips or pointers would be greatly appreciated

Thanks in advance

So, could you not store a starting value in a file?

1 | Out-File lastvalue.txt

And then…

$lastvalue = [int](Get-Content lastvalue.text)
$todaysvalue = $lastvalue++
$todaysvalue | out-file lastvalue.txt

?

I will give that a go and get back to you, thanks for the quick reply - great forum, I’m sure I’ll be spending a lot of time here!