Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

How to: Custom Object with [] addressing

$
0
0

Hi,

I have a requirement to create a testing framework for some PowerShell. The piece of PowerShell to be tested takes an object from an external source, that I don’t have access to, as a parameter so in my testing I need to create some dummies of this object. So I need to create some objects that can do some specific things. I know how to create a PsObject but in this case it needs to be able to have the following run over it:

$myObject["someProperty"] = "someValue" $theValue = $myObject["someProperty].Value 

So how do I set that up? I can write it so that I can address the variables like following:

$myObject.someProperty = "someValue" $theValue = $myObject.someProperty 

But I don’t know how to get the first way working. Any help appreciated.

Cheers, Yellephen

submitted by /u/Yellephen
[link] [comments]

The post How to: Custom Object with [] addressing appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Latest Images

Trending Articles



Latest Images