Powershell Script To Truncate SQL Log Files For All User Databases
This PowerShell script truncates the SQL log files for user databases on a SQL server. It uses the Invoke-SQLCMD cmdlet to query the sysdatabases and sys.master_files tables to get the database and log file names. For each user database, it sets the database to simple recovery, shrinks the log file, then sets the database back to full recovery. Logging messages are written to a log file with the server name and date in the filename.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
133 views1 page
Powershell Script To Truncate SQL Log Files For All User Databases
This PowerShell script truncates the SQL log files for user databases on a SQL server. It uses the Invoke-SQLCMD cmdlet to query the sysdatabases and sys.master_files tables to get the database and log file names. For each user database, it sets the database to simple recovery, shrinks the log file, then sets the database back to full recovery. Logging messages are written to a log file with the server name and date in the filename.