Courseiva
mediumMultiple ChoiceObjective-mapped

220-1102 Practice Question: A technician is writing a PowerShell script to…

A technician is writing a PowerShell script to retrieve the IP configuration of all computers in a domain and output the results to a CSV file. The script must run on a management workstation and target remote machines. Which cmdlet should the technician use to execute commands on remote computers?

⚠ Common exam trap

CompTIA often tests the distinction between interactive remote sessions (Enter-PSSession) and one-off command execution (Invoke-Command), leading candidates to choose Enter-PSSession when the requirement is to run a script against multiple computers and capture output.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Invoke-Command

Invoke-Command is the correct cmdlet because it is designed to execute PowerShell commands or script blocks on one or more remote computers and return the results to the local session. This allows the technician to run the IP configuration retrieval script against all domain computers from the management workstation and then pipe the output to Export-Csv.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Invoke-Command

    Why this is correct

    This cmdlet is the primary tool for executing script blocks or individual commands on one or more remote computers using PowerShell Remoting. It establishes a non-interactive session, runs the specified code, and efficiently returns the results to the calling machine, making it ideal for large-scale data collection and automation tasks across an enterprise network.

  • Enter-PSSession

    Why it's wrong here

    Unlike Invoke-Command, Enter-PSSession initiates a persistent, interactive session with a single remote computer, allowing a technician to directly type and execute commands as if logged in locally. While useful for detailed troubleshooting or direct administration of one machine, it is not designed for non-interactive scripting or simultaneously gathering data from multiple remote systems.

  • Get-WmiObject

    Why it's wrong here

    This cmdlet is used to retrieve instances of WMI classes, which can be queried from remote computers to gather system information. However, Get-WmiObject is considered deprecated in modern PowerShell versions, with Get-CimInstance being the preferred alternative, and it lacks the capability to execute arbitrary script blocks like Invoke-Command.

  • Out-File

    Why it's wrong here

    The Out-File cmdlet is designed to redirect the output of commands to a specified file on the local filesystem. It serves purely as an output formatter and writer, meaning it does not possess any functionality to execute commands on remote computers or initiate data retrieval processes from other machines.

About these practice questions

One of 495 original 220-1202 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 220-1202 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 220-1202 exam.