Powershell Tip: Increment Number Value at end of Variable/String using Foreach Loop

Many times there is a need to run through a list of servers or hostnames that have number increments and you don’t want to have to import a text file or csv.

I have a linux bash background and in bash you can do something like below to do a task against a list of servers:
for hostname in server{1..3}
do
echo $hostname
done
Output:
server1
server2
server3

In powershell you can use this format for it to work:
1..3 | % {“Server$_”}
The % is shorthand for foreach.
Server1
Server2
Server3

Now you can increment through a list of servers that are in numerical order!