diff --git a/journals/2026-06-11.md b/journals/2026-06-11.md index 6adf883..b5f3c5a 100644 --- a/journals/2026-06-11.md +++ b/journals/2026-06-11.md @@ -6,5 +6,4 @@ tags: [] Status: Active --- -Dzisiaj ogarniam rzeczy związan -moz \ No newline at end of file +Dzisiaj ogarniam rzeczy związanych z kontami i restorami, nie mam dzisiaj nic specjalnego do zapisania, pracuję dzisiaj do godziny 13:30 \ No newline at end of file diff --git a/toolbox/DBAToolBox.ps1 b/toolbox/DBAToolBox.ps1 index 44a7e24..bf25d58 100644 --- a/toolbox/DBAToolBox.ps1 +++ b/toolbox/DBAToolBox.ps1 @@ -44,6 +44,7 @@ $btnConnect = $Window.FindName("btnConnect") $txtServerName = $Window.FindName("txtServerName") $txtLogs = $Window.FindName("txtLogs") $dgServerInfo = $Window.FindName("dgServerInfo") +$dgServerErrors = $Window.FindName("dgServerErrors") $tvServers = $Window.FindName("tvServers") $btnAddServer = $Window.FindName("btnAddServer") $btnRemoveServer = $Window.FindName("btnRemoveServer") diff --git a/toolbox/Modules/SQLManager.psm1 b/toolbox/Modules/SQLManager.psm1 index 57477c8..6f1cf2d 100644 --- a/toolbox/Modules/SQLManager.psm1 +++ b/toolbox/Modules/SQLManager.psm1 @@ -123,4 +123,30 @@ GROUP BY d.name, d.state_desc, d.recovery_model_desc } } -Export-ModuleMember -Function Import-DBAToolBoxDependencies, Test-SQLConnection, Get-SQLDatabases \ No newline at end of file +function Get-SQLErrors { + <# + .SYNOPSIS + Gets SQL Server error log entries for the last hour using Get-DbaErrorLog. + #> + param( + [Parameter(Mandatory=$true)] + [string]$ServerInstance + ) + + try { + # Calculate time (1 hour ago) + $afterTime = (Get-Date).AddHours(-1) + $afterString = $afterTime.ToString("yyyy-MM-dd HH:mm:ss") + + # Call dbatools cmdlet to fetch log entries + $logs = Get-DbaErrorLog -SqlInstance $ServerInstance -After $afterString -LogNumber 0 -ErrorAction Stop + + # Clean select properties + $result = $logs | Select-Object LogDate, Source, Text + return $result + } catch { + throw "Failed to fetch SQL error log: $($_.Exception.Message)" + } +} + +Export-ModuleMember -Function Import-DBAToolBoxDependencies, Test-SQLConnection, Get-SQLDatabases, Get-SQLErrors \ No newline at end of file diff --git a/toolbox/UI/MainWindow.xaml b/toolbox/UI/MainWindow.xaml index 528ee30..dde30d4 100644 --- a/toolbox/UI/MainWindow.xaml +++ b/toolbox/UI/MainWindow.xaml @@ -68,7 +68,14 @@ - + + + + + + + +