Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
VM Creation Time from vSphere Power CLI
$vmProp = ""|Select VMname,CreatedTime
if ($CollectedEvent=$vm|Get-VMEvents -types 'VmBeingDeployedEvent','VmRegisteredEvent','VmClonedEvent','VmBeingCreatedEvent' -ErrorAction SilentlyContinue)
{
if($CollectedEvent.gettype().isArray){$CollectedEvent=$CollectedEvent|?{$_ -is [vmware.vim.VmRegisteredEvent]}}
$CollectedEventType=$CollectedEvent.gettype().name
$CollectedEventCreationDate=$CollectedEvent.CreatedTime
$vmProp.VMname=$CollectedEvent.vm.Name
$vmProp.CreatedTime=$CollectedEventCreationDate
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.