Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

IT-Wiki

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View my Codeberg Page

View my Photo Website

Array

published: March 3, 2015 author: Tinu tags: Array categories: PowerShell


Arbeiten mit Arrays in PowerShell.

Variable initialisieren

$array = @()

Werte zuweisen

$array = @('Single element')
foreach($item in $collection) {
    $array += '<new element>'
}
$array = @('element1','element2','element3')
$array = @(
    'element1,
    'element2',
    'element3'
)

Überprüfung auf Array

if ($array -is [system.array]){...}
if ($array $variable -isnot [system.array]){...}

Erstes Element auslesen

$array[0]

Letztes Element auslesen

$array[-1]

Anzahl Elemente auslesen

$array.length-1

← Previous Post ◇ [ Top ] ◇ Copyright © 2024 by tinuwalther ◇ [ Blog ] ◇ Next Post →