For a project I'm working on for work I've created an array that will receive the first number and last number in the array through user input. The first and last numbers are saved in a cfg file that holds data for various settings and is retreived through Get-Content.
For example the user wants the array to start at 0000 and end at 0092. Now what I want powershell to do for me is fill in all the missing the numbers in between 0000 and 0092 so it will eventually look like.
$array = @($firstNr, "0001", "0002", "0003", "0004", "0005", "0006", etc.. $lastNr)
In my search I've been looking through quite a lot of options already. Most of them didn't work for me unfortunately. None of the questions I've found online were what I wanted.
The official Microsoft documentation, stackoverflow nor other big PS help websites state much about the actions I'm looking to execute.
I'm hoping someone here can provide me an answer.
Thanks in advance!
If you need a filled array of strings with leading zeros, it should look something like this:
$beginNumber = 0
$endNumber = 92
$array = $beginNumber..$endNumber | ForEach-Object ToString('0000')
$array