This will give the first date when the VM was marked as a Template.
If you don't keep all the events, older templates might be missing a date.
Get-Template | Select Name,
@{N="HD#";E={@($_.ExtensionData.Config.Hardware.Device |
where{$_.GetType().Name -eq "VirtualDisk"}).Count}},
@{N="HD Size (KB)";E={[string]::Join(',',( $_.ExtensionData.Config.Hardware.Device |
where{$_.GetType().Name -eq "VirtualDisk"} |
%{$_.CapacityInKB}))}},
@{N="vCPU";E={$_.ExtensionData.Config.Hardware.NumCPU}},
@{N="RAM (MB)";E={$_.ExtensionData.Config.Hardware.MemoryMB}},
@{N="Created";E={(Get-VIEvent -Entity $_ -maxsamples ([int]::MaxValue) |
where {$_.GetType().Name -eq "TaskEvent" -and $_.Info.DescriptionId -eq "VirtualMachine.markAsTemplate"} |
Sort-Object -Property CreatedTime | Select -First 1).CreatedTime}} |
Export-Csv .\template-report.csv -NoTypeInformation -UseCulture
If you want to see the date the VM was created as the date, that requires re-writing the Where-clause