Invoke-DbaBalanceDataFiles View Source Sander Stad (@sqlstad), sqlstad.nl Windows, Linux, macOS Synopsis Re-balance data between data files
Description When you have a large database with a single data file and add another file, SQL Server will only use the new file until it’s about the same size.
You may want to balance the data between all the data files.
The function will check the server version and edition to see if the it allows for online index rebuilds.
Invoke-DbaDbDecryptObject View Source Sander Stad (@sqlstad), sqlstad.nl Windows, Linux, macOS Synopsis Decrypts encrypted stored procedures, functions, views, and triggers using Dedicated Admin Connection (DAC)
Description Recovers the original source code from encrypted database objects when the original scripts have been lost or are unavailable. This command uses the Dedicated Admin Connection (DAC) to access binary data from sys.sysobjvalues and performs XOR decryption to retrieve the original T-SQL code.
This is particularly useful in disaster recovery scenarios where you need to recreate objects but only have access to the encrypted versions in the database.
Invoke-DbaQuery View Source Friedrich Weinmann (@FredWeinmann) Windows, Linux, macOS Synopsis Executes T-SQL queries, scripts, and stored procedures against SQL Server instances with parameterized query support
Description Executes T-SQL commands against one or more SQL Server instances, supporting queries from strings, files, URLs, or SQL Server Management Objects. This is the primary dbatools command for running custom SQL against your environment, whether you’re extracting data for reports, deploying scripts across multiple servers, or running maintenance commands.
Join-DbaPath View Source Friedrich Weinmann (@FredWeinmann) Windows, Linux, macOS Synopsis Constructs file paths with correct separators for Windows and Linux SQL Server instances.
Description Constructs file paths by joining multiple segments while automatically using the correct path separators (backslash for Windows, forward slash for Linux) based on the target SQL Server instance’s operating system. This function eliminates the guesswork when building file paths for backup files, exports, scripts, or other SQL Server operations that need to reference files on the remote server.
New-DbaSqlParameter View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Creates a SqlParameter object for use with parameterized queries and stored procedures.
Description Creates a Microsoft.Data.SqlClient.SqlParameter object with specified properties like data type, direction, size, and value. This is essential for executing parameterized queries and stored procedures safely through Invoke-DbaQuery, preventing SQL injection while providing precise control over parameter behavior. Supports all SqlParameter properties including output parameters, table-valued parameters, and column encryption for secure data handling.
Read-DbaTransactionLog View Source Stuart Moore (@napalmgram), stuart-moore.com Windows, Linux, macOS Synopsis Retrieves raw transaction log records from a database using fn_dblog for forensic analysis and troubleshooting
Description Uses SQL Server’s built-in fn_dblog function to extract raw transaction log records from a live database, returning detailed information about every transaction in the format used by the SQL Server logging subsystem. This gives you access to the same low-level data that SQL Server uses internally to track database changes.
Repair-DbaInstanceName View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Updates SQL Server’s @@SERVERNAME system variable to match the Windows hostname
Description Updates SQL Server’s @@SERVERNAME system variable to match the current Windows hostname, which is required after renaming a Windows server. This ensures proper functionality for Kerberos authentication and Availability Groups.
The function automatically detects the correct new server name and uses sp_dropserver and sp_addserver to update the SQL Server system tables.
Reset-DbaAdmin View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Regains administrative access to SQL Server instances when passwords or access has been lost
Description Recovers access to SQL Server instances when you’re locked out due to forgotten passwords, disabled accounts, or authentication issues. This emergency recovery tool stops the SQL Server service and restarts it in single-user mode, allowing exclusive access to reset credentials and restore administrative privileges.
Resolve-DbaPath View Source Friedrich Weinmann (@FredWeinmann) Windows, Linux, macOS Synopsis Validates and resolves file system paths with enhanced error handling and provider verification.
Description Validates and resolves file system paths with additional safety checks beyond PowerShell’s built-in Resolve-Path cmdlet. This function ensures paths exist and are accessible before performing database operations like backups, restores, or log file management. It provides enhanced error handling, provider validation (FileSystem, Registry, etc.), and supports both existing paths and parent directories for new file creation.
Set-DbaMaxDop View Source Claudio Silva (@claudioessilva) Windows, Linux, macOS Synopsis Configures SQL Server maximum degree of parallelism (MaxDOP) at instance or database level
Description Configures the max degree of parallelism setting to control how many processors SQL Server uses for parallel query execution. Without a specified value, the function automatically applies recommended settings based on your server’s hardware configuration using Test-DbaMaxDop. This prevents performance issues caused by excessive parallelism on multi-core servers, especially in OLTP environments where parallel queries can create more overhead than benefit.