1.

Describe what is the benefit of Array in PowerShell?

Answer»

The USAGE of Array in PowerShell is to EXECUTE a script against remote computers. To build an array, you have to construct a VARIABLE and assign the array. Arrays are defined by “@”SYMBOL, they are portrayed as hashtable but are not followed by curly braces.

To utilize an array in a program, you must call a variable to reference the array, and you can define the kind of array the variable can reference. 

MENTIONED below is the syntax for declaring an array variable:

$A = 1, 2, 3, 4Or$A = 1..4

Note − By default type of object of the array is System.Object. GetType() method returns the type of the array. Type can be passed.

Example:

The mentioned code snippets are examples of this syntax −

[int32[]]$intA = 1500,2230,3350,4000$A = 1, 2, 3, 4$A.getType()


Discussion

No Comment Found