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
3
votes
0 answers

Network latency on docker container when it connects to SQL Server

I have a python flask application running inside a docker container. And I am using Test-DbaNetworkLatency to test the network latency between my application and SQL Server (running on premise). I found that the network latency is very slow when it…
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523
2
votes
1 answer

how to install a Powershell module in Powershell 4?

I have some machines on Powershell 4 In these machines even after I have placed the new powershell modules within the module path they don't show up in the Modules drop down list - as above. when I do the same thing in machines that are on…
2
votes
1 answer

How can I return the second column/property of an object in PowerShell?

I want to query SQL Server in PowerShell using Invoke-DbaSqlCmd. Invoke-DbaSqlCmd -SqlInstance DBA -Query 'exec xp_fixeddrives' This will return a System.Data.DataRow object. The object type is not really important. The important thing to know is…
PollusB
  • 1,726
  • 2
  • 22
  • 31
2
votes
1 answer

SQL database Restore using Powershell set Variable

Situation: We have a hosted application that we need direct access to the SQL server but not able to. The work around is the Host provides a weekly backup via SFTP. I have a Script that downloads the backup using WinSCP: CMD Batch Script ran to run…
Cody
  • 23
  • 5
1
vote
1 answer

How do I authenticate Azure App Service with Azure SQL without using passwords?

I have created an Azure SQL Server database and an Azure App Service, now I want to authenticate the application with the database, without using SQL authentication (no passwords). If I was doing this outside of Azure, I would need to create a login…
1
vote
2 answers

Powershell - The certificate chain was issued by an authority that is not trusted (dbatools)

I am using dbatools scripts, but most commands return: PS C:\Users\Administrator> Test-DbaDiskAlignment -ComputerName sqlag| Format-Table WARNING: [23:22:13][Get-DiskAlignment] Failure | The certificate chain was issued by an authority that is not…
Potter
  • 434
  • 8
  • 21
1
vote
0 answers

exporting views definition using Dba tools from synapse serverless database

i am able to export it but there are different schemas and i want to export only specific schema views. below is the dba tools script using. How can i add filter in below statement to get only specific schema views. Get-DbaDbview -SqlInstance…
1
vote
1 answer

Carbon Black Cloud blocking dbatools module

Wondering whether anyone has come across this and been able to find a workaround. When I try to run Import-Module dbatools (or any of the functions within the dbatools module), it is blocked by Carbon Black Cloud. The error in the ISE includes the…
1
vote
1 answer

SQL Server instance discovery using SqlServer PowerShell module

The dbatools module's Find-DbaInstance can accept a computer name and return a list of instances on that machine. Is there an equivalent in the SqlServer module that does this? I tried Get-SqlInstance, but it seems to need actual instance names, as…
1
vote
1 answer

Powershell DBATools Get-DbaDbTable is giving Error

I am trying to get Create Table script for Azure synapse ondemand pool instance using the following script. $connstring = ' ;Authentication="Active Directory Password";' $server = Connect-DbaInstance -ConnectionString…
nsr
  • 107
  • 1
  • 1
  • 7
1
vote
1 answer

PowerShell Array to Table like output -- Possible ForEach problem

I'm trying to run a sql query via PowerShell and return the results in a table-like format. It's putting multiple results in one field. I suspect there's something wrong with the 'foreach' loops. What am I missing, please? To use the code below,…
JM1
  • 1,595
  • 5
  • 19
  • 41
1
vote
0 answers

How to make use of the internal functions?

Basically we want to store backups on Azure Blob storage, yet Invoke-DbaDbLogShipping requires a $BackupNetworkPath. The closest I was to this was Azure File Shares but unfortunately port 445 is blocked it seems so I can't utilize that. I'm now…
Cataster
  • 3,081
  • 5
  • 32
  • 79
1
vote
0 answers

Powershell - Format-Table removing columns

I've been using Powershell with dbatools recently and still learning. When using format-table, I see it removes some columns from the result. It also does this when writing the result to a text file. I have tried format-table -autosize to no…
1
vote
1 answer

How to return multiple recordsets from stored procedure using PowerShell

I need to run a stored procedure that return 2 result sets with PowerShell. I use dbatools to do so but I could use .NET to get there. I just don't know how. For this example, I use exec sp_spaceused that will return the space used in the actual…
PollusB
  • 1,726
  • 2
  • 22
  • 31
1
vote
2 answers

How do I pass a variable to a function that satisfies a ValidateSet?

I am calling the dbatools Install-DbaInstance function, and one of the parameters is Feature. I initialize the variable to "Engine". If $bolSSIS -eq $true, I want to add "IntegrationServices" to the variable. If $bolSSAS -eq $true, I want to add…
wmeitzen
  • 90
  • 11
1
2 3 4 5 6