An IT technician is updating client logon scripts to automatically evaluate system parameters and set environment variables across different operating system environments. Which TWO of the following statements correctly describe variable syntax and environment features for Windows Batch (.bat) and PowerShell (.ps1) scripts? (Select TWO.)
- In a Windows Batch script (.bat), environment variables are referenced by enclosing the variable name in percent signs, such as %USERNAME%.Cevap
- In a PowerShell script (.ps1), variables are declared and referenced using a leading dollar sign, such as env:USERNAME.Cevap
- CIn a Windows Batch script (.bat), variables are defined using a leading dollar sign prefix and conditional comparisons require the -eq operator.
- DIn a PowerShell script (.ps1), environment variables are accessed using percent sign wrapping, such as %TEMP%.
Cevap
The correct answers are the statement describing Windows Batch script variable referencing using percent signs (%USERNAME%) and the statement describing PowerShell variable notation using a leading dollar sign ( env:USERNAME).
In Windows Batch (.bat) scripting, environment variables are called by enclosing their names in percent signs (e.g., %USERNAME%). In PowerShell (.ps1) scripting, variables always begin with a dollar sign prefix (e.g., env:USERNAME for environment variables). Both of these statements accurately represent their respective scripting language standards.
Adım Adım Çözüm
Anahtar Kavram
Scripting language syntax differences between Windows Batch (.bat) and PowerShell (.ps1)