VMware Cloud Community
RajuVCP
Hot Shot
Hot Shot

VM creation date for selected VM's

Hi All,

Happy Holidays to all.:smileycool:

does any of have the script which gives VM created date for the selected VM's (not all the vCenter VMs).

something like i will put the VM's name in text file (get-content)..:smileyconfused:

Thanks a ton in advance for help.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos
4 Replies
RvdNieuwendijk
Leadership
Leadership

The following PowerCLI script will retrieve the CreatedTime for all of the virtual machine names listed in a file called VMs.txt:

       

Get-VIEvent -Entity (Get-VM -Name (Get-Content -Path 'VMs.txt')) -MaxSamples ([int]::MaxValue) |
Where-Object {@('VmBeingDeployedEvent','VmRegisteredEvent','VmClonedEvent','VmBeingCreatedEvent') -contains $_.GetType().Name} |
Select-Object -Property CreatedTime,@{Name='VM';Expression={$_.Vm.Name}}
Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
RajuVCP
Hot Shot
Hot Shot

Thanks for your reply,

i just ran the script giving the path for the VM's mentioned in VMs text file.

But i didnt get any output. neither on powercli console...any thing am i missing..

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos
RvdNieuwendijk
Leadership
Leadership

If the virtual machines in the VMs.txt file are created a long time ago, the events related to the creation of the VMs might already have been removed from the eventlog.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
RajuVCP
Hot Shot
Hot Shot

Yes it looks old eventlog removed, but i can we get from vCenter Database.

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos