methuselah
methuselah

Reputation: 13206

Powershell - Piping information into an object

How would I pipe the information I've pulled out from a spreadsheet into a Powershell object?

$rangeAddr=$startCell + ":" + $endCell
    $sh.Range($rangeAddr).Value2 | foreach {
        New-Object PSObject -Property @{"Build"=$sh.Name;"AppName"=$_;}
    }

Upvotes: 0

Views: 135

Answers (1)

mjolinor
mjolinor

Reputation: 68273

I believe creating objects from hash tables was in V2, but not V1.

Does this work?

$rangeAddr=$startCell + ":" + $endCell
    $sh.Range($rangeAddr).Value2 |
      foreach {
        $NewObject = "" | Select Build,Name
        $Newobject.Build    = $sh.Name
        $NewObject.Name  = $_ 
        $NewObject
       }

Upvotes: 2

Related Questions