Courseiva
easyMultiple ChoiceObjective-mapped

220-1102 Practice Question: A system administrator is deploying a PowerShell…

A system administrator is deploying a PowerShell script to 100 computers to change the local administrator password. The script must run once per computer and then exit. Which scripting technique ensures the script runs exactly once on each machine?

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

Write a registry key after successful execution

This question covers idempotency and run-once mechanisms. Using a registry key or a marker file to record that the script has executed prevents it from running again on reboot or reapplication. Loops and parameters don't enforce a single execution.

Answer analysis

Option-by-option breakdown

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

  • Use a for loop to run the script 100 times

    Why it's wrong here

    A 'for' loop in PowerShell is designed to iterate a specified number of times, executing the enclosed code block repeatedly on the *local machine* where the script is running. This approach would cause the script to execute 100 times on *each* computer it's deployed to, rather than ensuring it runs only once per unique machine, which is the desired outcome for a one-time deployment task. It does not provide a mechanism to track execution status across different systems or prevent re-execution.

  • Write a registry key after successful execution

    Why this is correct

    Implementing a registry key as an execution flag is a robust method to ensure a script runs only once per machine. After the script successfully completes its intended task, it can create a specific registry key (e.g., HKLM:\SOFTWARE\MyCompany\MyScript\Executed). Subsequent executions of the script would first check for the presence of this key; if found, the script would immediately terminate, preventing redundant operations and ensuring idempotence on each target system.

  • Use a parameter to pass the computer name

    Why it's wrong here

    While using a parameter to pass a computer name is essential for targeting specific remote machines or for logging purposes, it does not inherently prevent a script from being executed multiple times on the *same* computer. A parameter merely provides input to the script; it offers no built-in mechanism to track whether the script has already run successfully on that particular machine in the past, thus failing to meet the requirement of a one-time execution per system.

  • Schedule the script to run daily

    Why it's wrong here

    Scheduling a script to run daily via Task Scheduler or similar mechanisms is designed for recurring tasks, not for a one-time deployment. This approach would cause the script to execute every 24 hours on each target machine, leading to continuous re-execution of the task. This directly contradicts the objective of a single, idempotent run per computer and could lead to unintended consequences, such as daily password changes or repeated software installations.

About these practice questions

This 220-1202 question is part of Courseiva's 495-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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.