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
1
vote
2 answers

DBATools Error: 'could not load file or assembly 'Microsoft.SqlServer.Replication.dll or one of its dependencies''

I'm running the below Powershell Export-DbaInstance -SqlInstance xxxxxx\xxxxxx -ExcludePassword -Exclude databases -Path \\xxxxx\xxxxx However, I'm getting the error 'WARNING: [14:34:02][Export-DbaRepServerSetting] Could not load replication…
1
vote
1 answer

HOW TO output the values of an array to a text file in a specified format

I'm using DBATools Module Invoke-DBQQuery ( based on Invoke-SQLCMD2) to query a SQL database. The query returns single record as a PSObject called $Results that looks like this... FileName : C12345 BADGENUMBER : BADGENUMBER=12345 LASTNAME…
Mark Buckley
  • 267
  • 1
  • 4
  • 14
1
vote
1 answer

I have installed the "install-dbatools" powershell script, but there is no copy-sqllogin or export-sqllogin function

I have installed the "install-dbatools.ps1" powershell module and it installs successfully, however the functions i am looking for are not there, these functions are "Copy-SQLLogin and "Export-SQLLogin" as per the…
Shaun
  • 23
  • 3
1
vote
0 answers

Invoke-DbaQuery Failure - The wait operation timed out

I try to run the following command: $serverName = 'firjt6' Invoke-DbaQuery -SqlInstance 'some site' -Database 'CM_IDC' -Query $query -SqlParameters @{SrvName = $serverName} And I keep on getting the following error: [Invoke-DbaQuery] Failure | The…
1
vote
3 answers

What are the options for the -Encoding parameter in the Import-DbaCsv tool?

I can't figure out what the Import-DbaCsv tool is expecting for the -Encoding parameter. The docs aren't helpful - https://docs.dbatools.io/#Import-DbaCsv I've tried UTF-8, UTF8, and UTF in upper case, lower case, with quotes, and without quotes. …
Daniel
  • 13
  • 3
1
vote
0 answers

Command GET-DBAOPERATINGSYSTEM: can a time out be set on this command?

Hi DBATOOLS Community, I'm using this great DBA powershell module to put in place a report script that will gather several metrics from all SQL Server I have in the company. But sometimes the GET-DBAOPERATINGSYSTEM command just get stacked with…
1
vote
0 answers

azure devops build task warning in powershell using dbatools

I have a azure devops powershell build task that is throwing warnings however, I am not sure how to capture those warning in the build logs. 2018-10-31T18:19:37.9619067Z WARNING: [13:19:37][Publish-DbaDacPackage] Deployment failed |…
1
vote
2 answers

Server Agent PowerShell job step - Difference between calling a file and calling a command

I have some simple PowerShell code to insert a value into a table: Invoke-SqlCmd -ServerInstance myserver -Query 'insert into Database.dbo.tbl values (1)' and if I save it as a file, I can call it in a CmdExec job step. However, can anyone tell me…
beehive
  • 93
  • 3
  • 11
0
votes
1 answer

How to suppress powershell confirmation DBATools New-DbaDbUser

I'm trying to use the dbatools functions New-DbaDbUser and Add-DbaDbRoleMember to avoid creating my own version, but struggle to get the confirmation pop up window skipped/suppressed. I have tried several combinations of -Force and -Confirm and so…
Cozzaro Nero
  • 129
  • 1
  • 8
0
votes
0 answers

Dbatools - Get-[DbaDatabase] Failure | The certificate chain was issued by an authority that is not trusted

I am new to powershell and dbatools and currently testing a script on an ec2 built-in Microsoft SQL Server 2022. This script should simply create full and differential backup jobs of all databases to a specified path and also pushes backups to a S3…
gklucard
  • 15
  • 6
0
votes
0 answers

Why am I not getting any output when using Get-DbaInstalledPatch via a Powershell script to gather SQL Server patch levels?

Using DBA Tools to gather a variety of information from a list of SQL Servers, particularly their patch level. I have a larger Powershell script that allows for selecting a set of options by entering their relevant number (1,2,3,4,5). I have been…
0
votes
1 answer

Powershell code for removing disabled AD logins doesn't work (doesn't remove) - what is wrong with the code?

I'm a beginner in Powershell. I'm trying to write a code using DbaTools module that gets AD logins from SQL Server, checks them against AD and removes logins for disabled AD users. The script seems to be running without errors, but on the following…
0
votes
0 answers

DBA Tools PowerShell: Backing up database

I am using this code to backup databases. There is 7 of them. The backup name will follow as the database name then the timestamp. I do not want the timestamp. I am not sure how to get rid of it. I tried adding -ReplaceInName and nothing…
movement
  • 33
  • 5
0
votes
0 answers

CREATE VIEW must be the only statement in the batch / Export-DbaScript - DBATools

I know that the solution is add a 'GO' statement at the begin of the code but the fact is, the final objective is a PowerShell script in order to automate the creation of all objects of a database and then start a new database creation in other…
0
votes
0 answers

DBATools and Overload SQLCommand and a clean ISE session

I have an older server with Powershell ISE, where I can't easily install vscode. I am trying to run DBATools.io's invoke-dbaquery using the ISE, but I get 'cannot find an overload for "sqlcommand"'. Looking online…
mbourgon
  • 1,286
  • 2
  • 17
  • 35