Soru

Zorluk: OrtaBasic Scripting Languages and Constructs

A desktop support technician is creating a PowerShell script (`.ps1`) to automate user account auditing on Windows 11 workstations. The script needs to evaluate whether a string variable containing an account status (`$accountStatus`) is equal to the value `"Disabled"` before taking remediation action. Which of the following comparison operators must the technician use inside the PowerShell `if` conditional statement?

  1. -eqCevap
  2. B
    ==
  3. C
    EQU
  4. D
    -is

Cevap

The technician must use the `-eq` operator inside the PowerShell conditional statement.
PowerShell (`.ps1`) uses hyphenated comparison operators rather than traditional mathematical symbols. The `-eq` operator tests for equality between values or strings within an `if` statement construct.

Adım Adım Çözüm

1
Identify the scripting environment.
The script is a PowerShell script (`.ps1`).
PowerShell has unique syntax rules for comparison operators compared to other scripting environments.
2
Determine the required logical operation.
An equality check between a variable and a string literal (`$accountStatus` and `"Disabled"`).
Conditional branching requires evaluating whether the target variable matches the specified criteria.
3
Select the correct PowerShell comparison operator syntax.
PowerShell uses hyphenated operators such as `-eq` for equality, `-ne` for inequality, `-gt` for greater than, and `-lt` for less than.
Using operators from other languages like `==` or legacy batch syntax like `EQU` will result in script parsing errors.

Anahtar Kavram

PowerShell Conditional Operators and Comparison Syntax
Bu soruyu puanla