Questions tagged [dbatools]

This tag should be used specifically for questions related to the PowerShell toolkit/scripts known as "dbatools"

The dbatools module is a PowerShell module that started out as just Start-SqlMigration, the brainchild of PowerShell MVP, Chrissy LeMaire. It has since grown into the SQL Server DBA's best friend.

The module is comprised of hundreds of commands that make the day-to-day task of being a SQL Server DBA easier, and more efficient. The current list of commands can be found on the module's site here.

Requirements

  • PowerShell 3.0 or higher
  • SQL Server SMO (installed via SSMS generally works).
  • The majority of the migration commands (Copy-Dbaxxx) are supported against SQL Server 200.
  • Other commands validate the version of SQL Server and will output if you are connecting to an unsupported version of the command.

Getting Started

This module is hosted both in the Microsoft's PSGallery and on GitHub under the SQL Server Community Collaborative project.

The PSGallery will contain the latest "master" version which is fully tested. You can install that version by simply running:

Install-Module dbatools

You can also hit the GitHub repository and run the install.ps1. This method will download the module and install it.

Not using the GitHub method will not support utilizing the PackageManagement module to update the module (e.g. Update-Module). You will have to run the command within dbatools Update-DbaTools.

77 questions
0
votes
1 answer

dbatools Invoke-DbaQuery truncates results at 90 characters

I'm using Invoke-DbaQuery to spool current application settings to a text file ahead of an application refresh but see the output is truncated at 90 characters. Does anyone know how to get past this limitation?
Ken
  • 77
  • 9
0
votes
0 answers

dbaTools fails to connect with Azure AD account on PowerShell Core

Using PowerShell Core 7.1.4, when I try to connect to my MS SQL instance using integrated security with an Azure AD account with Connect-DbaInstance from the dbatools module, I am met with an error message about login failed using NT…
0
votes
1 answer

Failed to convert parameter value from a SqlGuid to a String.(System.Data) when creating transaction log

I am applying log shipping to a database using Invoke-DbaDbLogShipping, and i am following the example in the documentation. The jobs get created and the Database is restored on the secondary server instance from what it appears, yet the jobs are…
Cataster
  • 3,081
  • 5
  • 32
  • 79
0
votes
1 answer

Copy-DbaAgentJob cmd with -Job parameter

while using Copy-DbaAgentJob dbatools cmd, what would need to passed to the parameter Job is it an array with the names of the jobs to be copied is it an array of actual jobs from the cmd Get-DbaAgentJob
Raghav
  • 125
  • 2
  • 10
0
votes
0 answers

ExecuteWithResults Exception?

I am running the following command as part of DB Log Shipping POC but getting exception: $params = @{ SourceSqlInstance = 'localhost' DestinationSqlInstance = 'localhost\MSSQLSERVER01' Database = 'Test' GenerateFullBackup = $true …
Cataster
  • 3,081
  • 5
  • 32
  • 79
0
votes
0 answers

How to capture warnings in dbatools commands?

Context: I need to be able to catch warnings that are preventing some backups from being restored when using the Restore-DbaDatabase cmdlet. I found some posts mentioning that the -Silent parameter for the Restore-DbaDatabase would treat those…
dsuy
  • 119
  • 5
0
votes
1 answer

PowerShell DbaTools Pass Hashtable to Invoke-DbaQuery

I am trying to pass a Hashtable called $SqlInstanceParams to the Invoke-DbaQuery dbatools command: Invoke-DbaQuery -SqlInstance "X" -Database "X" -Query "Set-SQLInstance" -SqlParameters $SqlInstanceParams -CommandType StoredProcedure Displaying the…
SteveH
  • 11
  • 2
0
votes
1 answer

Powershell dbatools - use CMS to get server name

forum.... still wkg on my POS skills. using dbatools.. I'm trying to run some informational queries, against multiple SQL instances. Is there a way to derive/use the server name from CMS to initialize the $server variable? How could I accomplish. …
SQLSeeker
  • 1
  • 1
0
votes
2 answers

Select values from Array based on name

I have extracted some details of a SQL instance using: $SQLInstance1 = Get-DbaInstanceProperty -SqlInstance SQL | Select-Object ComputerName, Name, Value | Where-Object Name -In ("FullyQualifiedNetName", "Edition", "PhysicalMemory", "Processors",…
SteveH
  • 11
  • 2
0
votes
0 answers

Mock Backup-DbaDatabase using Pester is not working

I have created a Powershell function that uses the Backup-DBADatabase in the DBATools module. It has some additional logic to create a framework for others to use consistently across the company. As a result I would like to use Pester to mock…
0
votes
0 answers

DBATools - Remove timestamp from Export-DBAScript -PATH

Is it possible to remove the timestamp when Export-DBAScript -PATH is used? I would just like to use the Server Name and Date. For example this is what I want to export: Get-DbaAgentJob -SqlInstance $ServerList| EXPORT-DBASCRIPT -PATH $FILENAME…
0
votes
1 answer

How to migrate SQL Server Instance from Local Instance to Azure VM SQL Server Instance using dbatools powershell?

How to migrate SQL Server Instance from Local Instance to Azure VM SQL Server Instance? Seeking for experts support resolving following issue. Scenario: LocalInstance: SQLSRV01 Azure VM: 23.96.20.20 -Local SQL SERVER and Azure VM SQL SERVER Instance…
Sameer
  • 349
  • 4
  • 12
0
votes
2 answers

Powershell filtering a property value without expanding the property name

Is it possible to filter the "Roles" property without using -expandproperty Roles? The first set of statement shows me what I needed except i couldn't filter Roles -eq "db_owner" and users -ne "user3" #import-module dbatools $servers =…
Laurent
  • 19
  • 1
  • 6
0
votes
1 answer

Easy method for deploying .sql script to multiple databases on a single instance

I have a dbscript.sql file that I would like to have run against roughly 30 databases sitting on a named SQL Server instance. The script is fairly lengthy (1000+ lines) and contains numerous quotes to change to accomodate using MS_ForEachDB. I had…
Geoff Dawdy
  • 886
  • 6
  • 15
  • 42
0
votes
0 answers

Invoke-DbaQuery Failure - Cannot open database ' ' requested by the login

I have this problem with my script. I am using dbatools $query= "select sid from sys.database_principals where type != 'R' " $SQLInstance='localhost\NEWINSTANCE' $databases=get-dbadatabase -SqlInstance $SQLInstance -ExcludeDatabase tempdb, master,…