Last Updated: February 25, 2016
·
372
· johnlbevan

Initialise PowerShell Array with Sequential Server Names

 $servers = (1..10 | %{"server{0:00}abc" -f $_}) `
         + (1..2   | %{"server{0:00}def" -f $_}) 


#output results:
$servers | %{ $_ }

<#
PowerShell code which initialises an array with a list of server names:
server01abc
server02abc
server03abc
server04abc
server05abc
server06abc
server07abc
server08abc
server09abc
server10abc
server01def
server02def
#>