Read-Host into an array.

$HostNumber = 1..60
$servers = foreach ($i in $HostNumber)
{
"$ServerPrefix{0:D2}$ServerPostfix" -f $i
}
$servers

I’m trying to make a script accept input with that, i just want users to enter an array of numbers “1..60” , “45,67,68”, or an even more ideal situation.. “1..45,67,68” and then perform actions on those servers. How would i go about generating numbers into an array from a read-host to accomplish this?

I’ve tried different variations, just can’t seem to get it.

submitted by /u/tadcrazio
[link] [comments]

Leave a Reply