PowerShell: Generate PC Lists using Foreach-Object and -f Operator

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

Generate PC Lists

One easy way of creating lists of PC names or IP address ranges etc is a simple pipeline like this:

1..40 | Foreach-Object { ‘PC-W7-A{0:000}’ -f $_ }

Use the -f operator to format the number. In this example, it will always be three-digit.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.