PowerShell Scripting – Déclarer un tableau


 

Déclarer comme :

$a = @()

# Initialise un tableau … utile pour des inputs successifs à stocker dedans par exemple

ou bien

[int32[]]$a

# Force l’utilisation de valeurs de type Int32 pour le tableau

Source : aide ci-desssous et Internet …

If the statement gets only a single process, the $LocalProcesses variable
would not be an array. To ensure the command creates an array, use the
array subexpression operator, @, as shown in the following example:

    $LocalProcesses = @(get-process co*)

Even if the command returns a single process, the $LocalProcesses variable
is an array. Even if it has only one member, you can treat it like any
other array. For example, you can add other objects to it. For more
information, see about_Operators.

http://technet.microsoft.com/en-us/library/dd315313.aspx


Comments (0)