Jun 2, 2026, 3:54 PM

This commit is contained in:
Paweł Domański
2026-06-02 13:54:37 +00:00
parent 3d99d13a2c
commit 04b2b6eeb7
3 changed files with 255 additions and 19 deletions
+29 -1
View File
@@ -44,4 +44,32 @@ function Test-SQLConnection {
}
}
Export-ModuleMember -Function Import-DBAToolBoxDependencies, Test-SQLConnection
function Get-SQLDatabases {
<#
.SYNOPSIS
Gets database information for a SQL Server instance.
#>
param(
[Parameter(Mandatory=$true)]
[string]$ServerInstance
)
try {
# Using Get-DbaDatabase from dbatools
$databases = Get-DbaDatabase -SqlInstance $ServerInstance -ErrorAction Stop
$dbList = @()
foreach ($db in $databases) {
$dbList += [pscustomobject]@{
Name = $db.Name
Status = $db.Status
Size = $db.Size
RecoveryModel = $db.RecoveryModel
}
}
return $dbList
} catch {
throw "Failed to get databases: $($_.Exception.Message)"
}
}
Export-ModuleMember -Function Import-DBAToolBoxDependencies, Test-SQLConnection, Get-SQLDatabases