0
0
PowerShellscripting~20 mins

CIM/WMI cmdlets in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CIM/WMI Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of Get-CimInstance for Win32_OperatingSystem
What is the output type of the following PowerShell command?
Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property Caption, Version
PowerShell
Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property Caption, Version
AA list of all running processes with their IDs
BAn object with properties Caption and Version showing OS name and version
CA string containing the full OS description
DAn error indicating the class Win32_OperatingSystem does not exist
Attempts:
2 left
💡 Hint
Think about what Win32_OperatingSystem class represents in WMI.
📝 Syntax
intermediate
2:00remaining
Correct syntax to query CIM instances remotely
Which option shows the correct syntax to get the list of services from a remote computer named 'Server01' using CIM cmdlets?
AGet-CimInstance -ClassName Win32_Service -ComputerName Server01
BGet-CimInstance -ClassName Win32_Service -Computer Server01
CGet-CimInstance -ClassName Win32_Service -RemoteName Server01
DGet-CimInstance -ClassName Win32_Service -Host Server01
Attempts:
2 left
💡 Hint
The parameter to specify a remote computer is -ComputerName.
🔧 Debug
advanced
2:00remaining
Identify the error in this CIM query
What error will this command produce?
Get-CimInstance -ClassName Win32_Process -Filter "Name = 'notepad.exe'"
PowerShell
Get-CimInstance -ClassName Win32_Process -Filter "Name = 'notepad.exe'"
AReturns empty result because no notepad.exe process is running
BSyntaxError due to incorrect filter string quotes
CNo error; returns all notepad.exe processes
DRuntime error: Invalid filter property 'Name'
Attempts:
2 left
💡 Hint
Check the filter syntax and property name carefully.
🚀 Application
advanced
2:00remaining
Using CIM cmdlets to restart a service
Which command correctly restarts the 'Spooler' service on the local computer using CIM cmdlets?
A$svc = Get-CimInstance -ClassName Win32_Service -Filter "Name='Spooler'"; Invoke-CimMethod -InputObject $svc -MethodName StopService; Invoke-CimMethod -InputObject $svc -MethodName StartService
BInvoke-CimMethod -ClassName Win32_Service -MethodName StopService -Arguments @{Name='Spooler'}; Invoke-CimMethod -ClassName Win32_Service -MethodName StartService -Arguments @{Name='Spooler'}
CRestart-Service -Name Spooler
DGet-CimInstance -ClassName Win32_Service -Filter "Name='Spooler'" | Restart-CimService
Attempts:
2 left
💡 Hint
You need to get the service instance first, then invoke methods on it.
🧠 Conceptual
expert
2:00remaining
Difference between Get-CimInstance and Get-WmiObject
Which statement best describes the difference between Get-CimInstance and Get-WmiObject cmdlets?
AGet-CimInstance only works locally; Get-WmiObject works remotely
BGet-CimInstance requires admin rights; Get-WmiObject does not
CGet-CimInstance returns raw XML; Get-WmiObject returns objects
DGet-CimInstance uses WS-Management protocol and is more efficient; Get-WmiObject uses DCOM and is deprecated
Attempts:
2 left
💡 Hint
Think about the communication protocols used by each cmdlet.