Questions tagged [dbatools]

For questions about dbatools, a PowerShell module to help SQL Server Pros be more productive.

Filter by
Sorted by
Tagged with
1 vote
1 answer
53 views

How to Filter and Restore Specific SQL Database Backups Using dbatools in PowerShell

I'm working with a directory of mixed SQL Server backup files and need to restore a specific database using dbatools in PowerShell. Below is the directory structure of my backup folder: PS C:\Users\...
Just a learner's user avatar
0 votes
0 answers
37 views

Uninstalling a SQL Server instance using dbatools

I don't know if this is the right forum for this question, please let me know if it isn't and kindly point me in the right direction. I have just started learning powershell and dbatools. I am trying ...
PTL_SQL's user avatar
  • 325
1 vote
1 answer
73 views

Why should I prefer Invoke-DbaQuery to its alternatives?

The documentation for Invoke-DbaQuery mentions many other similar functions This function is a wrapper command around Invoke-DbaAsync, which in turn is based on Invoke-SqlCmd2. It was designed to be ...
J. Mini's user avatar
  • 135
1 vote
0 answers
66 views

DBATools.io - Copy-DbaLogin - unable to copy logins for AAD Groups

We are wanting to copy all the Logins from one Azure Managed Instance to another. We are using the DBATools.io powershell command "Copy-DbaLogin" to do this. We are using the -Force option ...
Mike's user avatar
  • 658
0 votes
0 answers
52 views

Using dbatools powershell module with azure automation hybird worker groups

We want to use dbatools powershell module with azure automation . We already have dbatools module on hybird worker group machines . We tested the code we want to run by directly logging into the ...
yegnasew's user avatar
  • 487
0 votes
1 answer
236 views

Error with dbatools

Trying to export SQL Objects via DBAtools in Powershell. Get-DbaAgentJob -SqlInstance 'TestServer01' -Job 'mydatabase-daily-backup' | Export-DbaScript -FilePath C:\temp\mydatabase-daily-backup.sql ...
Prakash's user avatar
0 votes
0 answers
49 views

Restart Remote SQL SERVER Engine Using DBAtools

I have installed dbatools on a central server to remotely manage SQL servers. All the servers are part of a workgroup. I need to be able to remotely restart the SQL Server service whenever it's ...
kedar's user avatar
  • 23
0 votes
1 answer
30 views

Run Policy Based Management On Central Management Server with Code

I have a jump\terminal server to administer 100 SQL Servers and want to evaluate my locally created policies across all the servers by using the Central Management Server but WITHOUT: creating the ...
Stackoverflowuser's user avatar
1 vote
1 answer
330 views

Powershell script SQL Server AvailabilityGroups

I am really new to Powershell and hopefully someone can help me with this error. I have been given the below script that is supposed to take a list of SQL servers from a text file and lists out the ...
Underhill Julian's user avatar
0 votes
1 answer
941 views

Can we change the parameter of Find-DbaAgentJob?

Can we change the parameter of Find-DbaAgentJob? Hi there, I got "[Find-DbaAgentJob] Failure | Error connecting to [xxx.yyy.zzz]: The certificate chain was issued by an authori ty that is not ...
DBALUKE HUANG's user avatar
1 vote
0 answers
128 views

dbatools, DbcCheck Does not use Saved credential

Last week I deployed dbccheck on the production environment. I found strange thing and have no idea what the problem is. We have 40 db vm's which are not domain joined. Each of db vm's have same ...
kedar's user avatar
  • 23
0 votes
0 answers
66 views

Rollback a write-dbadatatable with the truncate flag?

I'm using the dbatools for our SQL Server 2019 server. When I try to import an Excel sheet, I would like to truncate the table before importing the new rows. This is possible if I add the -Truncate ...
Henrik Staun Poulsen's user avatar
1 vote
1 answer
782 views

DBATools :: how to query Azure SQL Databases with MFA

I'm following the official DBATools guide regarding how to query Azure SQL Databases. This code is working: $azureCredential = Get-Credential -Message 'Azure Credential' $azureAccount = Connect-...
Francesco Mantovani's user avatar
0 votes
2 answers
440 views

dbatools import csv help!

Is there a way I can import csv files with the proper data types into MSSQL table using PS dba tools? I'm using this below command but all I get is a table and all the columns are nvarchar(max): ...
SAKA UK's user avatar
  • 90
0 votes
2 answers
747 views

Get total size of all databases with DBATools

Using DBATools, is there a recommended way to get the summed total size of all DBs for a given server?
user2368632's user avatar
  • 1,087
0 votes
1 answer
630 views

Copy users to other database with the same permissions

We use dbatools to migrate/copy databases to other servers. This sometimes means that we restore a database with a different name (ex: database => database_Test). When I use the Copy-DbaLogin ...
M_B's user avatar
  • 1
0 votes
1 answer
1k views

MySQL Trigger to prevent update in one table if particular data is available in another table

I need a MySQL trigger that can prevent update of a particular column data, if some specific data is available in another table. I have two tables product and sales. Product Sale I need to prevent ...
PRAMOD MANN's user avatar
0 votes
1 answer
333 views

Exporting multiple TSQL result sets into one spreadsheet using Powershell

I have to load a lot of CSV files into a DB (3 at a time, resulting in one table per CSV, named as the file name and headers are). I then run about 12 different stored procedures using those table ...
scarr030's user avatar
  • 115
1 vote
0 answers
79 views

Get Queries History from SQL Server Database

I started a new job as DBA, and one of the tasks is to run backups and stuff but since it's my first experience I would like to get a general idea about the databases I'll be managing, for that I want ...
Hamza Hamdani's user avatar
1 vote
3 answers
582 views

How to restore automatically the latest of 10 .bak files from a blob container?

I am trying to have a copy of a transactional database on another server restored once a day for reporting purposes. SQL Server is the instance. Original database is a member of an Availability Group. ...
TheNixon's user avatar
  • 361
0 votes
1 answer
3k views

Invoke-DbaQuery not working on new server, Cannot find an overload for "SqlCommand"

I've ran the install script both without and with the -Force parameter from the Getting Started doc on github Install-Module dbatools -Scope CurrentUser Install-Module dbatools -Scope CurrentUser -...
DForck42's user avatar
  • 3,038
0 votes
1 answer
322 views

Run T-SQL Script Using Powershell via SQL Agent Job

Tried to think of the best subject title; however having a problem getting this done. I'll give my preferred way, but open to any best method to get this done. I have a tsql script that is done, ...
SQLSeeker's user avatar
1 vote
0 answers
236 views

Unable to execute dbachecks command

i installed dbachecks module in a server. but when i am trying to execute get-dbccheck, it is throwing the below error Populating RepositorySourceLocation property for module Pester. VERBOSE: Loading ...
Saravana Kumar's user avatar
0 votes
1 answer
861 views

Passing in multiple instances into the dbatools command GET-DBADBFILE

I am attempting to gather all of the dbfile information on all of our sql instances in one of our environments. It is a fairly large environment and would be tedious to perform one instance at a time. ...
Geoff Dawdy's user avatar
  • 1,123
0 votes
1 answer
64 views

Migrate database to Azure

I have a 600GB database that I must transfer from an on-premises machine to an on Azure VM machine (IaaS) I would like to use the dbatools copy-database tool for this for this I will have to know what ...
Abdallah Mehdoini's user avatar
0 votes
1 answer
191 views

How can I add timestamp into my table when I use Write-DbaDbTableData?

I am trying to use one table to store the SQL server disk space checking data by dbatools: $allservers_PRD | Get-DbaDiskSpace | Write-DbaDbTableData -SqlInstance MySQL2019 -Database SQL_DBA_TASK -...
DBALUKE HUANG's user avatar
1 vote
1 answer
785 views

how can I get only the SQL server logins, when we use Export-dbalogin

when we run the export-dbalogin, it will will generate a script(.sql) file, which we will run the in the destination server, then the logins will be migrated, but this command will give both windows ...
Harsh Sanghai's user avatar
1 vote
1 answer
520 views

How do I pass a variable into -job on Copy-DbaAgentJob?

I'm trying to query one the source instance and copy across any missing jobs into the destination instance. Everything seems to work except passing the name into -job. Can anyone suggest a fix or ...
TuckRollworthy's user avatar
0 votes
2 answers
741 views

Powershell dbatools combining result of multiple Get-dbaxxx commands to generate a report

I'm new to powershell and dbatools. It is a great tool but when I try to combine the result of few different commands into an array to be exported to csv, it is not providing the intended result. It ...
Ali's user avatar
  • 195
0 votes
1 answer
3k views

Encrypt connection when using sqlcmd

Trying to connect database with an encrypted connection, tried below sql queries: sqlcmd -N -E -S tcp:SQLSERVER,1234 -U username -P password -d Database -Q "INSERT INTO table1 VALUES(1,2,2) ERROR:...
chris's user avatar
  • 103
0 votes
1 answer
575 views

How to find port using Get-DbaTcpPort

How to find whether the port used by SQL Server is static or dynamic using Get-DbaTcpPort dbatools command? Below command doesn't show whether it's static/dynamic: Get-DbaTcpPort -sqlinstance TEST ...
SQLPRODDBA's user avatar
  • 1,908
4 votes
1 answer
430 views

Should dbatools be installed on all SQL Servers

I'm looking to leverage dbatools powershell module for our SQL Server management needs. The install process does not lend itself for installation across a large number of servers. Is it really ...
Russ960's user avatar
  • 359
0 votes
1 answer
399 views

Importing dbatools module into Azure Automation Account

Has anyone managed to import dbatools module into Azure Automation Account? I tried to do it in several ways, but every time the installation fails: different versions checked from 0.9.* to the ...
GrzegorzO's user avatar
  • 338
1 vote
1 answer
214 views

Sync Server Objects when having two or more Availability Groups

Lets imagine that i have two servers/nodes with TWO availability groups Group01 and Group02. I will need to ensure that the server objects are all the time recreated over the secondary replica. If i ...
Claudio Domingos's user avatar
0 votes
1 answer
87 views

Can Set-DbaAgReplica filter any SqlInstances out

I have been working with an Availability Group with an extra asyncronous secondary, that is always set to manual failover. I am worried that if I ran: Get-DbaAgReplica -SqlInstance x -...
Luke Duddridge's user avatar
6 votes
2 answers
2k views

Process to change collation on a database

I've been asked to change the collation on a database that has been in production for a few years as it was not set correctly at the time of deployment. So my research shows that in order change ...
Tony Hinkle's user avatar
  • 7,939
0 votes
1 answer
434 views

dbatools start-dbamigration running very slowly

I am trying to use the powershell module dbatools to migrate one SQL Server instance to a new instance on a VM. The new VM is on a different physical server than the source. I am not migrating the ...
GHauan's user avatar
  • 603
3 votes
2 answers
218 views

DBATools - pass through flat file configs to Agent Job Commands

I'm experimenting with source controlling my SQL Agent Jobs & Schedules as .json files and deploying them with the dbatools SQL Agent command suite. Given $sa = Get-Credential and foo.config of ...
Peter Vandivier's user avatar
2 votes
1 answer
3k views

DBATools offline install - export-dbainstance was not found

I followed the instruction at https://dbatools.io/offline/: download zip & unzip run $env:PSModulePath to find all the paths. copy to C:\Program Files\WindowsPowerShell\Modules. run Get-ChildItem ...
James's user avatar
  • 93
0 votes
1 answer
639 views

dbatools - Copy all jobs to the other node - selected jobs only

Is it possible to copy all sql server agent jobs using dbatools from one node to another, except a particular job? or perhaps just copy a set of jobs?
test's user avatar
  • 103
2 votes
3 answers
1k views

How can the System databases in SQL Server 2016 be moved using Powershell?

I'm trying to move the system databases using Powershell ie. without using any T-SQL. Using SMO : Install-Module SQL-SMO $smo = New-SMO -ServerName localhost $smo.databases["TempDB"]....
Ayan Mullick's user avatar
1 vote
2 answers
304 views

dbatools, DbcCheck LastBackup

Last week I started testing dbccheck on my test system. I found one strange thing, and I have no idea what is the problem, last fullbackup is few hours old, but dbccheck print an error. Following you ...
KW_1970's user avatar
  • 11
1 vote
2 answers
107 views

Test-DbaDiskAlignment Not Working

PS H:\> Test-DbaDiskAlignment -ComputerName Test_Server WARNING: [Test-DbaDiskAlignment][22:09:54] Can't connect to Test_Server WARNING: [Test-DbaDiskAlignment][22:09:54] CIM query to ...
Halt_And_Catch_Fire's user avatar
7 votes
4 answers
6k views

SQL Agent PowerShell task never finishes

I'm quite new to PowerShell, and now I've found dbatools.io, where I would like to run a PowerShell task in SQL Agent like $ExportPath = $env:TEMP + '\DriveSpace.csv' $datatable = Import-Csv $...
Henrik Staun Poulsen's user avatar
6 votes
3 answers
2k views

SQL Agent PowerShell Syntax Error

I am attempting to setup a PowerShell script within a SQL Agent job (SQL Server 2016). I'm using a third party module, DBATOOLS.psd1 which appears to be where I'm getting my syntax error. Currently my ...
Geoff Dawdy's user avatar
  • 1,123
2 votes
1 answer
1k views

Get-MSSQLLinkPasswords Powershell script doesn't seem to work under SQL Server 2016

I've been using the Get-MSSQLLinkPasswords Powershell script for a long time and it has been a huge help. The script decrypts the passwords for all linked servers on a particular Windows server and ...
Scott Hodgin - Retired's user avatar