updated – with version check, uptime
I figured out how to do get variables from a query. So i added a second get-sqldata function within the loop
Because i have a mixed environment i need a version check to set the sysprocess table or view -The new columns will need to be added to the merge statement in the the previous script and the table updated
if ($srv.Version.ToString() -lt "9.00.0000.00")
{$sysprocesses = "sysprocesses"}
else
{$sysprocesses = "sys.sysprocesses"}
#Write-Host $sysprocesses
function Get-SqlListsstarttime
{
Get-SqlData $Server "master" "SELECT login_time AS Started ,DATEDIFF(DAY, login_time, CURRENT_TIMESTAMP) AS daysUptime FROM $sysprocesses where spid = 1;
" | foreach {$_.started,$_.daysUptime} |
foreach { $uptimeList.Add("$_") > $null }
}# gets time started and uptime
Get-SqlListsstarttime
$started = $uptimelist[0]
$daysuptime = $uptimelist[1]
