NET Framework, you can literally
use any variable or object type available in the .NET Framework when defining
your variables. Following are the most common variable types:
?–? [boolean] True or false
?– [int] 32-bit integer
?– [char] Single character
?– [string] String of characters
?– [single] Single-precision floating number (a number containing
decimals??”i.e., 1.232)
?– [double] Double-precision floating number (the same as single except it
allows for a greater range of values and precision)
?– [datetime] Date or time
?– [adsi] ADSI object
?– [wmi] WMI instance or collection
?–? [wmiclass] WMI class
446 Microsoft Windows Server 2008 Administration
The result of this little code snippet above would be first 2nd third being displayed
on the screen on one line. Just like many programming languages, the arrays are 0 index
??“based, so $myArr[0] refers to the first element, $myArr[1] refers to the second
element, and so on. Notice how you implicitly defined $myArr as having three data elements;
but what if you wanted to add two more? In VBScript, you would have had to use
the ReDim statement to resize the array. But in PowerShell, this is extremely easy:
$myArr = "first","second","third"
$myArr = $myArr + "fourth","fifth"
write-host $myArr[4]
This code snippet results in the string fifth being displayed on the screen. Notice
that all you had to do to extend my existing array was to add the new data elements
you wanted using the plus (+) operator.
Pages:
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474