VMware Cloud Community
xacolabril
Expert
Expert
Jump to solution

DataStore creation date time?

Hello. It is possible to know a DataStore creation date time?

thank you in advance!

Xavier Colomé Abril. VMware Certified Professional VCP3, VCP4 and VCP5. [Si encuentras que esta o cualquier otra respuesta ha sido de utilidad, vótalas. Gracias.] [If you find this or any other information helpful or correct, please consider awarding points. Thank you.]
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Afaik the datastore object has no creation date property.

But you can use the events, provided you keep these long enough.

This simple script will show you the datastorename and it's creation date.

Get-VIEvent -Start (Get-Date).AddMonths(-2) -MaxSamples 99999 | `
where{$_.GetType().Name -eq "VMFSDatastoreCreatedEvent"} | `
Select @{N="Name";E={$_.Datastore.Name}},CreatedTime,UserName

You can play with the Start parameter to change the time to go back.

The MaxSamples parameter needs to be provided by a huge number, otherwise you risk not getting all the events for the interval. It depends of course on the activity in your vSphere environment.


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

View solution in original post

0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

Afaik the datastore object has no creation date property.

But you can use the events, provided you keep these long enough.

This simple script will show you the datastorename and it's creation date.

Get-VIEvent -Start (Get-Date).AddMonths(-2) -MaxSamples 99999 | `
where{$_.GetType().Name -eq "VMFSDatastoreCreatedEvent"} | `
Select @{N="Name";E={$_.Datastore.Name}},CreatedTime,UserName

You can play with the Start parameter to change the time to go back.

The MaxSamples parameter needs to be provided by a huge number, otherwise you risk not getting all the events for the interval. It depends of course on the activity in your vSphere environment.


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

0 Kudos
aevrov
VMware Employee
VMware Employee
Jump to solution

Hi Xacolabril,

You can get the events and look for the datastore creation event for the datastore in question:

$ds = Get-Datastore datastore_name
$event = Get-VIEvent | where { $_.FullFormattedMessage -like "created *" -and $_.Datastore -and $_.Datastore.Datastore.ToString() -eq $ds.Id }

$event.CreatedTime

Regards,

- Angel

LucD
Leadership
Leadership
Jump to solution

Angel, I'm afraid you will only get 100 events in the current build with that Get-VIEvent statement


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

0 Kudos
aevrov
VMware Employee
VMware Employee
Jump to solution

Yes, you should specify a bigger -MaxSamples value so you can get older events, e.g. -MaxSamples [int]::MaxValue

- Angel

0 Kudos
aevrov
VMware Employee
VMware Employee
Jump to solution

Luc, you should also expect the NFS datastore creation event, besides VMFS.

...
where { $_.GetType().Name -eq "VMFSDatastoreCreatedEvent" -or
$_.GetType().Name -eq "NASDatastoreCreatedEvent" }
...

- Angel

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Thanks Angel, you could indeed include the NAS event as well if you want to see the NAS datastore creation times.


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

0 Kudos
xacolabril
Expert
Expert
Jump to solution

Thank you friends.

It would be nice in future versions of PowerCLI. By other hand I've been thinking, and although not with PowerCLI, from the Service Console, we could see from a: ls -ltr /vmfs/volumes/ (we can see a creatin date in each linux soft link for each DataStore)...

Xavier Colomé Abril. VMware Certified Professional VCP3, VCP4 and VCP5. [Si encuentras que esta o cualquier otra respuesta ha sido de utilidad, vótalas. Gracias.] [If you find this or any other information helpful or correct, please consider awarding points. Thank you.]
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You are correct, the timestamp of the links shows the creation date, but on the other hand the COS will soon disappear.

And with ESXi it will not be that easy to get at these links.


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

JP112
Contributor
Contributor
Jump to solution

Hey Luc,

if i need to know only for single data store creation date/time, is it possible ?

For example datastore name is DS01 and i need to know creation date/time

Regards,

0 Kudos
LucD
Leadership
Leadership
Jump to solution

On the Get-VIEvent you can pass an Entity parameter, try with the datastore object as value.

Not sure if that will filter the create events though.

An alternative you might try is to use the 'Datastore' folder (Get-Folder -Name Datastore) as value on the Entity parameter.


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

0 Kudos