Get-DbaDatabaseLastUsed
Is this a feature OR bug: Enhancement
https://trello.com/c/s2fnvD0C
Additional comments @Jagoop "Use data from sys.dm_db_index_usage_stats to determine when the database was last used by users. Max of last_user_seek, last_user_scan, last_user_lookup = last time a user read. last_user_update = last time a user wrote/updated.
The method isn't foolproof, but combined with the database created timestamp and the instance restert (from tempdb creation date), it can assist in discovering databases that are unused."
@wsmelton "Reading "Watch-SqlDbLogin" it would seem this may be close or just another option to doing the same thing for databases. Watch command is named for logins but it can be the same premise around databases as well.
But this command could still prove useful. Could also add in something fancy like just doing a "Watch-DbaDatabase" instead and periodically poll the index usage stats....or create an Trace/XEvent to watch for login activity, then load that into table or display output."
@SQLDBAWithABeard - would you be able to add this property to Get-DbaDatabase? Ensuring that it's only added for servers that support it, otherwise, $null. If not, let me know. i recall you loving that in dbareports.
Absolutely
yessssss!
this got merged a while ago. Closing.