A collection is a container that groups multiple values or objects as one data object. Picture it as an in-memory table: each object is a row, and its properties are columns. section 8.1
Store several computer names
PowerShell creates a collection from a comma-separated list: $computers = 'SRV-02','SERVER1','localhost'. Displaying $computers shows three separate string objects, one per line. Keep commas outside the quotation marks; placing them inside creates one string containing commas. section 16.4
Collections support several practical operations:
- Access a property across the collection: $processes.Name. PowerShell implicitly unrolls the collection and retrieves the Name property from each process; ForEach-Object and Select-Object -ExpandProperty provide equivalent forms. section 16.4.4
- Test membership with -contains or -in. For example, $collection -contains 'abc' checks whether the string exists, while 'abc' -in $collection reverses the operand order. section 26.2.4
- Iterate through every item with foreach; its script block runs once for each object in the collection. section 23.1.1
$processes = Get-Process $processes.Name
Run $processes = Get-Process followed by $processes.Name to observe property unrolling across a collection of process objects. section 16.4.4















