# Use the Pipeline, Not an Array

A very common mistake made by traditional programmers who come to PowerShell - which is not a programming language:

![image057.png](/files/-LA8qUbL9jtW8KuQpPG8)

This person has created an empty array in $output, and as they run through their computer list and query WMI, they're adding new output objects to the array. Finally, at the end, they output the array to the pipeline.

Poor practice. You see, this forces PowerShell to wait while this entire command completes. Any subsequent commands in the pipeline will sit their twiddling their thumbs. A better approach? Use the pipeline. Its whole purpose is to accumulate output for you - there's no need to accumulate it yourself in an array.

![image059.png](/files/-LA8qUbjVhbKNx0kKMRy)

Now, subsequent commands will receive output as its being created, letting several commands run more or less simultaneously in the pipeline.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devops-collective-inc.gitbook.io/the-big-book-of-powershell-gotchas/use-the-pipeline-not-an-array.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
