Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to create a custom object with mutliple attributes that can be accessed.

$
0
0

Hey guy,

Have a quick question to see if I can get some feedback.

I am needing to create an 'object' that has multiple attributes associated with it.  Much like a HashTable, but instead of it only having a 'Name' and 'Value' that can be accessed, (I am probally not using the right wording but you can get an idea of what I need for my end result from my example) I need to create something in powershell that is an object that can have multiple items to access such as

$object1 = ("headerItem1", "headerItem2", "headerItem3", "headerItem4")

$object1.add ("testrow1a", "testrow1b", "testrow1c", "testrow1d")

$object1.add ("testrow2a", "testrow2b", "testrow2c", "testrow2d")

And I would like to be able to access it like you would any other PowerShell object - such as

$object1.HeaderItem1

and it would return

     testrow1a

     testrow2a

Let me know what you think, or if anyone can offer assistance.    [I know I can do it through creating a CSV, but I don't want to do it through that, I would like to create an Object, and then access it from there.)


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>