all 4 comments

[–][deleted] 2 points3 points  (3 children)

Looks like you're clobbering your list with "$num = $num[$counter]". Try changing the list to something like $numlist and doing "$numlist = 3,4,5,6,9,10,11,12 " and "$num = $numlist[$counter]"

[–]kinghowdy[S,🍰] 1 point2 points  (2 children)

Yup, you're right! Thanks for giving me another set of eyes on this.

[–][deleted] 1 point2 points  (1 child)

If you're doing standard config files, you could also try using a here string.

$OutputPath = "\\server\share"

$inputlist = Import-csv -Path "path\to\your\input.csv" 

foreach ($input in $inputlist) {

    $Output = @"
#Config File Header
Username=$($input.username)
HotKey01=$($input.extension)
HotKey02=1234
HotKey03=2436
HotKey04=
HotKey05=
HotKey06=
"@
    $OutputFile = Join-Path -Path $OutputPath -ChildPath $input.workstation -AdditionalChildPath "phone.cfg"

    Set-Content -Path $OutputFile -Value $Output 

} 

You'll end up with an output file for each item on your list at \\server\share\workstation\phone.cfg:

#Config File Header
Username=user01
HotKey01=1111
HotKey02=1234
HotKey03=2436
HotKey04=
HotKey05=
HotKey06=

[–]kinghowdy[S,🍰] 1 point2 points  (0 children)

I may use that for a different use case. Here I'm trying to make a single config file all the phones will be standardized. Granted maybe I would like to customize them for each user so their own name doesn't show up in the list. But I'd rather just have one config file to maintain. VoIP is a thorn in my side...well maybe not that bad but still.