Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 228891

Re: Creating a table and rows

$
0
0

Hello-

 

Yes, you can make an object of any type that you please.  The New-Object example that I gave was using an object type of "System.Management.Automation.PSCustomObject".  You can specify properties/members as you wish.

 

And, yes, you could have 3 or 5 or 10 or x properties on the PSObject.  Like:

 

## create a new object
$oMyObject=New-Object-TypeNamePSObject-Property @{
    VMName
="myVM"
    Disk0GB
=40
    Disk1GB
=10
    DStoreName
="ssd01"
    OwnerName
="Big Matt"
    RetireDate
=Get-Date"Apr 2017"
}
## end new-object

 

The contents of the object are then:

VMName   Disk0GB   Disk1GB   DStoreName   OwnerName   RetireDate
------   -------   -------   ----------   ---------   ----------
myVM          40        10   ssd01        Big Matt    4/1/2017 12:00:00 AM

 

And, you can see the members of the object and each of their types (using Get-Member):

 

## get the members of the object
$oMyObject | Get-Member

 

That shows the members, that some are Int32, some are String, and some are DateTime objects as properties of the PSObject:

     TypeName: System.Management.Automation.PSCustomObject

Name        MemberType   Definition
----        ----------   ----------
Equals      Method       bool Equals(System.Object obj)
GetHashCode Method       int GetHashCode()
GetType     Method       type GetType()
ToString    Method       string ToString()
Disk0GB     NoteProperty System.Int32 Disk0GB=40
Disk1GB     NoteProperty System.Int32 Disk1GB=10
DStoreName  NoteProperty System.String DStoreName=ssd01
OwnerName   NoteProperty System.String OwnerName=Big Matt
RetireDate  NoteProperty System.DateTime RetireDate=4/1/2017 12:00:00 AM
VMName      NoteProperty System.String VMName=myVM

 

 

Make sense?


Viewing all articles
Browse latest Browse all 228891

Trending Articles