Pipe array to Powershell script

I created a Powershell script to set a few mailbox properties. I wanted to pipe in an array of mailbox objects, i.e. the results of a Get-Mailbox command, like so:

$Mailboxes | C:\Set-MailboxProperties.ps1

However, Set-MailboxProperties.ps1 only processed the first item in the array.

Via Google I found this helpful StackOverflow post, How to pass an array as a parameter to another script? Although the answers did not include an example exactly like mine, their solution works just the same:

(,$Mailboxes) | C:\Set-MailboxProperties.ps1

Leave a Reply

Your email address will not be published. Required fields are marked *