VMware Cloud Community
johanham
Contributor
Contributor
Jump to solution

VMs created the last month

Hi,

Is there a simple way using powercli to query vCenter for how many VMs that has been deployed the last month?

Would like to see the name and creation date property

Regards

Johan

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

If you are using vSphere 6.7 or later, you can indeed use that property.
And as long as none of those VMs have been removed in the meantime.

To limit to last month, you could do

Get-Cluster 'clu' | Get-VM |

where{$_.CreateDate -ge (Get-Date).AddMonths(-1)} |

Sort-Object -Property CreateDate |

select name,createdate


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

You can look for the events with Get-VIEvent.
Something like this Solved: Report: The creator of VM, who created ... |VMware Communities


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

0 Kudos
johanham
Contributor
Contributor
Jump to solution

Thanks for the swift response LucD!

I came up with this : Get-Cluster 'clu' | Get-VM | select name,createdate | sort createdate

Would be nice if I could filter this with get-date somehow.... 
See VMs created for example the last 14 days/30days

Regards

Johan

0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you are using vSphere 6.7 or later, you can indeed use that property.
And as long as none of those VMs have been removed in the meantime.

To limit to last month, you could do

Get-Cluster 'clu' | Get-VM |

where{$_.CreateDate -ge (Get-Date).AddMonths(-1)} |

Sort-Object -Property CreateDate |

select name,createdate


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

0 Kudos
johanham
Contributor
Contributor
Jump to solution

Perfekt!!  many thanks Smiley Happy

0 Kudos