Jun 11, 2026, 1:19 PM
This commit is contained in:
@@ -6,5 +6,4 @@ tags: []
|
|||||||
Status: Active
|
Status: Active
|
||||||
---
|
---
|
||||||
|
|
||||||
Dzisiaj ogarniam rzeczy związan
|
Dzisiaj ogarniam rzeczy związanych z kontami i restorami, nie mam dzisiaj nic specjalnego do zapisania, pracuję dzisiaj do godziny 13:30
|
||||||
moz
|
|
||||||
@@ -44,6 +44,7 @@ $btnConnect = $Window.FindName("btnConnect")
|
|||||||
$txtServerName = $Window.FindName("txtServerName")
|
$txtServerName = $Window.FindName("txtServerName")
|
||||||
$txtLogs = $Window.FindName("txtLogs")
|
$txtLogs = $Window.FindName("txtLogs")
|
||||||
$dgServerInfo = $Window.FindName("dgServerInfo")
|
$dgServerInfo = $Window.FindName("dgServerInfo")
|
||||||
|
$dgServerErrors = $Window.FindName("dgServerErrors")
|
||||||
$tvServers = $Window.FindName("tvServers")
|
$tvServers = $Window.FindName("tvServers")
|
||||||
$btnAddServer = $Window.FindName("btnAddServer")
|
$btnAddServer = $Window.FindName("btnAddServer")
|
||||||
$btnRemoveServer = $Window.FindName("btnRemoveServer")
|
$btnRemoveServer = $Window.FindName("btnRemoveServer")
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -68,7 +68,14 @@
|
|||||||
|
|
||||||
<!-- Main Content Area -->
|
<!-- Main Content Area -->
|
||||||
<GroupBox Grid.Row="1" Header="Server Information" Margin="0,0,0,10" Foreground="#2D3E50" FontWeight="SemiBold">
|
<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>
|
</GroupBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user