Which code declares an array of three machine names in PowerShell?

Study for the Tanium Technical Account Manager Interview Test. Prepare with flashcards and multiple choice questions, each with hints and explanations. Ace your interview with confidence!

Multiple Choice

Which code declares an array of three machine names in PowerShell?

Explanation:
The idea being tested is how to declare an array literal in PowerShell. The code builds an array by using the array subexpression operator and listing three string elements separated by commas: 'machine1', 'machine2', and 'machine3'. This array is then assigned to the variable. Using single quotes makes each element a literal string, which is fine here, though double quotes would also work if you needed interpolation. The key is that the elements are three distinct items separated by commas inside the array literal, giving you exactly three machine names. The other patterns shown either use an invalid separator, omit an element, or would still work but aren't as explicit for this exact three-item array.

The idea being tested is how to declare an array literal in PowerShell. The code builds an array by using the array subexpression operator and listing three string elements separated by commas: 'machine1', 'machine2', and 'machine3'. This array is then assigned to the variable. Using single quotes makes each element a literal string, which is fine here, though double quotes would also work if you needed interpolation. The key is that the elements are three distinct items separated by commas inside the array literal, giving you exactly three machine names. The other patterns shown either use an invalid separator, omit an element, or would still work but aren't as explicit for this exact three-item array.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy