Get-DbaUptime

Returns the uptime of the SQL Server instance, and if required the hosting windows server

By default, this command returns for each SQL Server instance passed in:

SQL Instance last startup time, Uptime as a PS TimeSpan, Uptime as a formatted string
Hosting Windows server last startup time, Uptime as a PS TimeSpan, Uptime as a formatted string

Screenshots

Examples

To return an object with SQL Server start time, uptime as TimeSpan object, uptime as a string, and Windows host boot time, host uptime as TimeSpan objects and host uptime as a string for the sqlexpress instance on winserver

Get-DbaUptime -SqlInstance SqlBox1\Instance2

To return an object with SQL Server start time, uptime as TimeSpan object, uptime as a string, and Windows host boot time, host uptime as TimeSpan objects and host uptime as a string for the sqlexpress instance on host winserver and the default instance on host sql2016

Get-DbaUptime -SqlInstance winserver\sqlexpress, sql2016

To return an object with SQL Server start time, uptime as TimeSpan object, uptime as a string for the sqlexpress instance on host winserver and the default instance on host sql2016

Get-DbaUptime -SqlInstance sqlserver2014a, sql2016 -SqlOnly

To return an object with SQL Server start time, uptime as TimeSpan object, uptime as a string, and Windows host boot time, host uptime as TimeSpan objects and host uptime as a string for every server listed in the Central Management Server on sql2014

Get-SqlRegisteredServerName -SqlServer sql2014 | Get-DbaUptime

Author

This command was created by Stuart Moore. You can find Stuart on Twitter and his blog.