A tier 2 support technician is auditing administrative scripts created for system maintenance across multi-platform client devices. The technician must identify syntax elements and construct formats specific to Microsoft PowerShell (`.ps1`). Which of the following statements correctly describe PowerShell scripting syntax and variable usage? (Select TWO)
- Variables in PowerShell are designated with a dollar sign prefix (e.g., env: namespace.Answer
- Comparison operations in PowerShell conditional statements utilize hyphenated operators such as -eq (equal) and -gt (greater than) instead of standard mathematical symbols.Answer
- CEnvironment variables must be wrapped inside percent signs (e.g., %serviceState%), and conditional constructs require a THEN keyword before script execution blocks.
- DVariable assignment requires explicit declaration using the SET keyword, and string values must be enclosed in square brackets instead of quotes.
Answer
PowerShell variables are prefixed with a dollar sign with environment variables using the $env: prefix, and PowerShell comparison operations use hyphenated operators such as -eq and -gt rather than traditional comparison symbols.
PowerShell scripts (.ps1) use a dollar sign ( env: drive provider prefix to access environment variables. In addition, PowerShell utilizes hyphenated comparison operators (such as -eq, -ne, -gt, and -lt) within conditional statements to avoid syntax conflicts with shell redirection operators.
Step-by-Step Solution
Key Concept
PowerShell Scripting Syntax and Constructs