0
0
PowerShellscripting~20 mins

CIM/WMI cmdlets in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Using CIM/WMI Cmdlets in PowerShell
📖 Scenario: You are a system administrator who wants to gather information about the computer's operating system using PowerShell. You will use CIM/WMI cmdlets to query system details.
🎯 Goal: Build a PowerShell script that retrieves the operating system's caption and version using CIM/WMI cmdlets and displays the information.
📋 What You'll Learn
Create a variable with the CIM class name for the operating system
Create a variable to store the property names to retrieve
Use Get-CimInstance with the class name to get OS info
Select only the specified properties from the CIM instance
Display the operating system caption and version
💡 Why This Matters
🌍 Real World
System administrators often need to gather system information remotely or locally to manage computers efficiently. CIM/WMI cmdlets provide a powerful way to query this data.
💼 Career
Knowing how to use CIM/WMI cmdlets is essential for IT professionals and system administrators to automate system monitoring and reporting tasks.
Progress0 / 4 steps
1
Set CIM class name variable
Create a variable called $cimClass and set it to the string 'Win32_OperatingSystem'.
PowerShell
Need a hint?

The CIM class for operating system info is Win32_OperatingSystem.

2
Set properties to retrieve
Create a variable called $properties and set it to an array containing the strings 'Caption' and 'Version'.
PowerShell
Need a hint?

Use an array with @('Caption', 'Version') to list the properties.

3
Retrieve OS information using Get-CimInstance
Use Get-CimInstance with the class name stored in $cimClass and store the result in a variable called $osInfo. Then select only the properties in $properties from $osInfo.
PowerShell
Need a hint?

Use Get-CimInstance -ClassName $cimClass and pipe to Select-Object -Property $properties.

4
Display the operating system information
Write a Write-Output statement to display the operating system caption and version from $osInfo in the format: Operating System: [Caption], Version: [Version].
PowerShell
Need a hint?

Use Write-Output with string interpolation to show the caption and version.