dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Having a transaction log file with too many virtual log files (VLFs) can hurt database performance.

Too many VLFs can cause transaction log backups to slow down and can also slow down database recovery and, in extreme cases, even affect insert/update/delete performance.

SQL Skills

If you’ve got a high number of VLFs, you can use Expand-SqlTLogResponsibly to reduce the number.




Returns all user database virtual log file counts for the sqlcluster instance.

Get-DbaDbVirtualLogFile -SqlInstance sqlcluster

Returns user databases that have 50 or more VLFs.

Get-DbaDbVirtualLogFile -SqlInstance sqlserver | Where-Object {$_.Count -ge 50}

Returns all VLF information for the sqlserver and sqlcluster SQL Server instances. Processes data via the pipeline.

@(‘sqlserver’,’sqlcluster’) | Get-DbaDbVirtualLogFile

Returns the VLF counts for the db1 and db2 databases on sqlcluster.

Get-DbaDbVirtualLogFile -SqlInstance sqlcluster -Database db1, db2


This command was created by Chrissy LeMaire. You can find Chrissy on Twitter.


From PowerShell, execute Get-Help Get-DbaDbVirtualLogFile -Detailed for more information on this function.

Source Code

Want to see the source code? View Get-DbaDbVirtualLogFile.ps1 on GitHub

Related commands