0
0
PowerShellscripting~15 mins

Environment variables in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Environment variables
📖 Scenario: You are writing a PowerShell script to manage environment variables for a simple application setup. Environment variables store important settings like paths or configuration values that your script can use.
🎯 Goal: Build a PowerShell script that creates a new environment variable, reads an existing environment variable, and then displays the values.
📋 What You'll Learn
Create a new environment variable with a specific name and value
Read the value of an existing environment variable
Display both environment variable values using Write-Output
💡 Why This Matters
🌍 Real World
Managing environment variables is common when setting up software, configuring scripts, or customizing user environments.
💼 Career
Many IT, DevOps, and scripting jobs require working with environment variables to automate setups and deployments.
Progress0 / 4 steps
1
Create a new environment variable
Create a new environment variable called MyAppPath and set its value to C:\MyApp\bin using PowerShell syntax.
PowerShell
Need a hint?

Use $env:VariableName = 'Value' to set environment variables in PowerShell.

2
Read an existing environment variable
Create a variable called systemPath and assign it the value of the existing environment variable PATH using PowerShell syntax.
PowerShell
Need a hint?

Use $variable = $env:VariableName to read environment variables.

3
Display the environment variable values
Use Write-Output to display the values of MyAppPath and systemPath variables on separate lines.
PowerShell
Need a hint?

Use Write-Output $variable to print values in PowerShell.

4
Run the script and check output
Run the script to print the values of MyAppPath and systemPath. The output should show C:\MyApp\bin on the first line and the full PATH value on the second line.
PowerShell
Need a hint?

The first line of output must be exactly C:\MyApp\bin. The second line will be your system's PATH value.