Work with Object Variables in Windows PowerShell

Learners, in the Work with Object Variables in Windows PowerShell, an IT Pro Challenges virtual lab, assign an object variable and figure out its methods and properties, in addition to its other members. Skills gained in this lab helps those on a Cyber Operator and Exploitation Analyst career path with simple scripting, critical in their work.

45 minutes
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *

Already have an account? Sign In »


This lab introduces learners to simple PowerShell scripting, how to make, and find out about a variable. The instructions contain guided hints along the way, through completion, where learners may check their work. Preparation requires connecting to a Remote Desktop and some familiarity with the PowerShell interface preparation needed to start the lab.

Mac users need to download the Microsoft Remote Desktop application to run the lab. Lab machines, part of Azure’s resources, may take up to 10 minutes to complete a provision. While the machine is set up, learners can scan the lab instructions, becoming familiar with the tasks. Learners need to wait until their machines have started before connecting to start the lab, or they run into problems. Users see a message bubble appear when their virtual systems are ready.

Including object variables in PowerShell scripts can help streamline tasks like managing a large number of servers at once. Understanding variable properties and methods show how to manipulate variables within the scripts and get commands to manage systems effectively.

Furthermore, object, method, and property concepts appear in other programming languages such as Javascript, Python, and many more. Objects, in scripting, describe entities in containers conceived and defined by the person creating the script. So, this lab introduces basic coding practices in a friendly, easily accessible way.

Configure Your Environment:

In this section, learners set up their environments to run the PowerShell commands. Upon initiating and connecting to their remote desktops, lab participants launch the PowerShell application. From there, they create a Class directory and navigate to that folder. At this point, the lab configuration completes.

Determine the Properties and Methods of an Object Variable:

Learners create an object variable called $Spooler that retrieves information about the print spooler. PowerShell has a series of objects built into its library. Their members consist of commands that an object variable (in the case of $Spooler all the print servers) can do or can act upon that object variable. Displaying these members gives users access to functions all ready to go and information about what these members do and how the scripter needs to form requests using them.

Access the Members of an Object:

This exercise has learners use some of the methods retrieved in the previous section. Participants run the commands on the object variable, as listed by the Get-Member command, and view the output and results. The methods or properties follow a dot notation after the variable. Also, the learner sees that a property, such as “Status” can be run with many objects. Users retrieve the status of the variable and then the status of the servers, after stopping the server.


When the learner finishes this virtual lab, he or she demonstrates comfortableness:

  • Creating an object variable
  • Listing the members of an object variable, which includes methods and properties
  • Using methods and properties to manipulate an object variable.

Those that finished the lab may wish to consider practicing and extending their skills through IT Challenges Automated Administration PowerShell - Challenge Series.