Jun 2, 2026, 3:54 PM
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user