{"id":1473,"date":"2016-05-04T14:52:55","date_gmt":"2016-05-04T19:52:55","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=1473"},"modified":"2016-05-04T14:52:55","modified_gmt":"2016-05-04T19:52:55","slug":"pipe-array-to-powershell-script","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2016\/05\/pipe-array-to-powershell-script\/","title":{"rendered":"Pipe array to Powershell script"},"content":{"rendered":"<p>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:<\/p>\n<p><code>$Mailboxes | C:\\Set-MailboxProperties.ps1<\/code><\/p>\n<p>However, Set-MailboxProperties.ps1 only processed the first item in the array.<\/p>\n<p>Via Google I found this helpful StackOverflow post, <a href=\"http:\/\/stackoverflow.com\/questions\/7152740\/how-to-pass-an-array-as-a-parameter-to-another-script\">How to pass an array as a parameter to another script?<\/a> Although the answers did not include an example exactly like mine, their solution works just the same:<\/p>\n<p><code>(,$Mailboxes) | C:\\Set-MailboxProperties.ps1<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/osric.com\/chris\/accidental-developer\/2016\/05\/pipe-array-to-powershell-script\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Pipe array to Powershell script<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[393],"tags":[247,228],"class_list":["post-1473","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-array","tag-powershell"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=1473"}],"version-history":[{"count":2,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1473\/revisions"}],"predecessor-version":[{"id":1487,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1473\/revisions\/1487"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=1473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=1473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=1473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}