Quick script (as always) to get the vlf counts for all your databases via powershell. Bit of a misnomer though, it just executes the sql for each database. AFAIK, there is no mechanism in SMO to retrieve the vlf count directly. This uses SQLPSX.
param(
[string]$serverName = "ServerName"
)
Import-Module SqlServer
$outputs = @();
$qry = @"
DBCC LOGINFO
"@
$server = Get-SqlServer -sqlserver $serverName
$dbs = Get-SqlDatabase -sqlserver $server | where{$_.IsSystemObject -ne $true}
foreach($db in $dbs)
{
$res = Get-SqlData -dbname $db.name -sqlserver $server -qry $qry
$output = New-Object -TypeName PSObject -Property @{
DatabaseName = $db.Name
VLFCount = $res.Count
}
$outputs += $output
}
$outputs | Format-Table -AutoSize
Leave a comment