Jun 11, 2026, 1:19 PM

This commit is contained in:
Paweł Domański
2026-06-11 11:19:26 +00:00
parent 7804484b98
commit 71f53cec15
4 changed files with 37 additions and 4 deletions
+1 -2
View File
@@ -6,5 +6,4 @@ tags: []
Status: Active
---
Dzisiaj ogarniam rzeczy związan
moz
Dzisiaj ogarniam rzeczy związanych z kontami i restorami, nie mam dzisiaj nic specjalnego do zapisania, pracuję dzisiaj do godziny 13:30
+1
View File
@@ -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")
+27 -1
View File
@@ -123,4 +123,30 @@ GROUP BY d.name, d.state_desc, d.recovery_model_desc
}
}
Export-ModuleMember -Function Import-DBAToolBoxDependencies, Test-SQLConnection, Get-SQLDatabases
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
+8 -1
View File
@@ -68,7 +68,14 @@
<!-- Main Content Area -->
<GroupBox Grid.Row="1" Header="Server Information" Margin="0,0,0,10" Foreground="#2D3E50" FontWeight="SemiBold">
<DataGrid x:Name="dgServerInfo" AutoGenerateColumns="True" IsReadOnly="True" Background="White" BorderBrush="#CCCCCC" Margin="5"/>
<TabControl Background="White" BorderBrush="#CCCCCC" Margin="5">
<TabItem Header="Details">
<DataGrid x:Name="dgServerInfo" AutoGenerateColumns="True" IsReadOnly="True" Background="White" BorderBrush="Transparent" Margin="5"/>
</TabItem>
<TabItem Header="Errors (Last Hour)">
<DataGrid x:Name="dgServerErrors" AutoGenerateColumns="True" IsReadOnly="True" Background="White" BorderBrush="Transparent" Margin="5"/>
</TabItem>
</TabControl>
</GroupBox>
</Grid>