0
0
PowerShellscripting~15 mins

Range operator (..) in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Range operator (..)
📖 Scenario: You are helping a small store owner who wants to list product IDs for a sale. The IDs are numbers in a sequence. You will use PowerShell's range operator to create this list easily.
🎯 Goal: Build a PowerShell script that uses the range operator .. to create a list of product IDs from 101 to 110, then display them.
📋 What You'll Learn
Create a variable called productIDs using the range operator .. to include numbers from 101 to 110
Create a variable called startID and set it to 101
Use the range operator with startID to create productIDs
Print the productIDs variable to show the list of IDs
💡 Why This Matters
🌍 Real World
Range operators help quickly create lists of numbers, useful for IDs, dates, or steps in automation scripts.
💼 Career
Knowing how to generate sequences with range operators is a basic skill for scripting tasks in IT, DevOps, and automation roles.
Progress0 / 4 steps
1
Create the product ID list using the range operator
Create a variable called productIDs and set it to the range of numbers from 101 to 110 using the range operator ...
PowerShell
Need a hint?

Use .. between two numbers to create a sequence. For example, 1..5 creates numbers 1 to 5.

2
Create a start ID variable
Create a variable called startID and set it to 101.
PowerShell
Need a hint?

Just assign the number 101 to the variable startID.

3
Use the startID variable with the range operator
Update the productIDs variable to use the startID variable as the start of the range and 110 as the end of the range.
PowerShell
Need a hint?

Use the variable startID on the left side of the .. operator.

4
Display the product IDs
Print the productIDs variable to display the list of product IDs.
PowerShell
Need a hint?

Use Write-Output $productIDs to print the list in PowerShell.