VMware Cloud Community
jeffj2000
Enthusiast
Enthusiast

Anyway to get when a Tag was applied to a VM?

Hi. I hope everyone is safe. We are exploring the use of Tags again as we move from v6.5U2 to v7.0U1. Is there anyway to determine the date of when a Tag was applied to a VM? For instance when we recommit a VM we usually powerOFF and then update the in the notes 30d on when it can be deleted, and we have some crazy scripts to attempt to find this because as you know the notes are free-form and people just don't follow instructions on the format. It would be nice to simply have people apply a Tag and the script can just look for who has the tag and the date it was applied. But I do not see anyway to do that so I thought I would ask here. I had actually thought I could simply do a script that runs daily and when it finds a tag, puts the VM name in aa text filr with the date or just creates a file with the date and then the script also scans that when it runs to determine when 30d is up to send the emails. Im not a expert in Powershell but that seems something I can google and piece together. Thanks,,,

0 Kudos
2 Replies
LucD
Leadership
Leadership

You could do something like this.
Note that you will have to adapt the Start parameter value to what period you want to cover.
You can also limit the VMs for which to look for events by using the Entity parameter.

Get-VIEvent -Start (Get-Date).AddMinutes(-15) -MaxSamples ([int]::MaxValue) |
where {$_ -is [VMware.Vim.EventEx] -and $_.EventTypeId -eq 'com.vmware.cis.tagging.attach'}


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

0 Kudos
jeffj2000
Enthusiast
Enthusiast

Hi. Thank you very much I will try this today and thank you for being so active on here, you should write a book I would buy it to support your efforts on here. Thanks,,,

0 Kudos