Hello. It is possible to know a DataStore creation date time?
thank you in advance!
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
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
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
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
Yes, you should specify a bigger -MaxSamples value so you can get older events, e.g. -MaxSamples [int]::MaxValue
- Angel
Luc, you should also expect the NFS datastore creation event, besides VMFS.
...
where { $_.GetType().Name -eq "VMFSDatastoreCreatedEvent" -or$_.GetType().Name -eq "NASDatastoreCreatedEvent" }
...
- Angel
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
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)...
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
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,
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