I'm a newbie of powershell, I'm starting right now to look at objects, etc. I'm creating an object in this way:
$myObject = [PSCustomObject]@{
ComputerName = "abc"
Data = "xxx"
}
If I then print $myObject
what i get is:
ComputerName Data
------------ ----
abc xxx
And everything is ok, now I want to add a property to that object, and I saw (tell me if i'm wrong) that I can do it in 2 ways: with add-member
and with select-object
For example with add-member
what I did was:
$myObject | Add-member -NotePropertyName Level -NotePropertyValue Highest
Instead with Select-object
I did:
$myobject = 2 (cause i want to add 2 properties, is it right?) | Select-Object -Property Level, Privilege
$myobject.Level = "High"
$myobject.Privilege = "Elevated"
Now if I run $myobject
I still only get:
ComputerName Data
------------ ----
abc xxx
- What should I do to see all the data, even the one that I added later?
- Can I directly add the values to the properties added through
Select-Object
? Thanks