Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Working with Variables in PowerShell Core for Linux

You can store all types of values in PowerShell variables. For example, store the results of commands, and store elements that are used in commands and expressions, such as names, paths, settings, and values. This lab will cover the concepts of creating and using variables in PowerShell for Linux.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Beginner
Last updated
May 11, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Perform a system update, register the MS RedHat repository, and install PowerShell
    1. Use the yum command to sync the package index files from their sources via the Internet:
    sudo yum check-update
    
    1. Use the yum command to install the newest versions of all installed packages on CentOS:
    sudo yum update
    
    1. Register the Microsoft RedHat Repository:
    curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
    
    1. Install PowerShell:
    sudo yum install -y powershell
    
    1. Start PowerShell:
    pwsh
    
  2. Challenge

    Work with Creating, Changing, Using, and Removing Variables
    1. Set a variable named MyVar and enter the integers 10, 11, and 12 as values:
    $MyVar = 10, 11, 12
    
    1. Set a variable named Path and enter the path "/home/cloud_user/" as the value:
    $Path = "/home/cloud_user"
    
    1. Set a variable name Process and set the cmdlet Get-Process as the value:
    $Processes = Get-Process
    
    1. Set a variable named Today and set the value as (Get-Date).DateTime as the value:
    $Today = (Get-Date).DateTime
    
    1. Call the variable MyVar and observe the output:
    $MyVar
    
    1. Call the variable Today and observe the output:
    $Today
    
    1. Call the variable Path and observe the output:
    $Path
    
    1. Call the variable Processes and observe the output:
    $Processes
    
    1. Change the value of MyVar to 15,16,17
    $MyVar = 15,16,17
    
    1. Call the variable MyVar and observe the change in the output:
    $MyVar
    
    1. Change the value of MyVar to "The Blue Dog"
    $MyVar = "The Blue Dog"
    
    1. Call the variable MyVar and observe the change in the output:
    $MyVar
    
    1. Clear the variable MyVar using both the Clear-Variable and $null methods":
    Clear-Variable -Name MyVar
    $MyVar = $null
    
    1. Call the variable MyVar and observe the change in the output:
    $MyVar
    
    1. Remove the variable MyVar using the Remove-Variable cmdlet:
    Remove-Variable -Name MyVar
    
    1. Run the cmdlet Get-Variable and verify that MyVar is not in the list of variables:
    Get-Variable
    
    1. Exit PowerShell
    exit
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight