Try [array]$eject_tapes += $tape.location You're reassigning $eject_tapes every time through the loop and not appending a value.
From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Behalf Of Daniel Chenault Sent: Monday, April 6, 2015 3:06 PM To: powershell@lists.myitforum.com Subject: [powershell] reference elements I thought I had this right, but apparently not. It's my understanding that when selecting multiple attributes of a cmdlet's output it creates an array. Yet it's not working. $eject_tapes = $null $all_tapes = Get-ProtectionGroup -DPMServer SD-SCDPM-01 | Get-Tape | Select Label, Barcode, Location | Sort-Object Label | ft -autosize foreach ($tape in $all_tapes) { if ($tape.label -like "*monthly*" -and $tape.location -ne "offline") { $eject_tapes = $tape.location } } out-file -filepath "c:\users\danielcadmin\documents\tapes.txt" -inputobject $eject_tapes Output file is empty and shouldn't be. Doing this manually I see it's not picking up that I want the element. I've also tried $tape.[0] without joy. This is part of a larger project BTW. ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1 ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1