VMware Cloud Community
vespavbb
Enthusiast
Enthusiast
Jump to solution

Limit Output of createdTime

$report = $vms.values | select-object Name, Powerstate, NumCpu, MemoryGB, Notes,

@{N="Cluster";E={$_.vmhost.parent}},

@{N="Last PowerOff";E={Get-VIEvent -Entity $_ -MaxSamples ([int]::MaxValue) | where {$_ -is [VMware.Vim.VmPoweredOffEvent]} | select createdTime}},

@{ n="Space on Datastore"; e={[math]::round( $_.ProvisionedSpaceGB, 2 )}} | convertto-html -Head $strHtmlHead

the Poweroff command bring out to much

it looks like this

@{CreatedTime=10/14/2019 10:47:14 AM}

How can I limit it to the Date only?

like-> 10/14/2019 10:47:14 AM

ps the imput $vmsvalues is a arry of VM´s

VCP4,VCP5,VCP6,VCP7,VCP8
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Use the ExpandProperty parameter

@{N="Last PowerOff";E={Get-VIEvent -Entity $_ -MaxSamples ([int]::MaxValue) | where {$_ -is [VMware.Vim.VmPoweredOffEvent]} | select -ExpandProperty createdTime}},


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Use the ExpandProperty parameter

@{N="Last PowerOff";E={Get-VIEvent -Entity $_ -MaxSamples ([int]::MaxValue) | where {$_ -is [VMware.Vim.VmPoweredOffEvent]} | select -ExpandProperty createdTime}},


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
vespavbb
Enthusiast
Enthusiast
Jump to solution

oh wow,

you are a real scripting Boss!

Thanks

VCP4,VCP5,VCP6,VCP7,VCP8
0 Kudos