dbatools – Auto Updatin’2 min read


Are you a dbatools enthusiast like I am?  Have you been introduced to the greatness?

Well here is hoping you said yes to both questions and you are using dbatools on a daily basis.  dbatools has changed the daily routine of hundreds of DBA’s around the world.  You do not have to be a PowerShell professional developer to use the tools and commands.

I have been using dbatools heavily since I was introduced to it.  I have automated processes and created new processes with it.  There are new commands that come out almost daily that fill in certain gaps or enhance current commands.  One way to stay current with these updates is to update your dbatools install frequently.

How better to do this than to have an auto update process that will run daily and get the latest dbatools version for you…

I have put together two ways of doing this based on your preferred method.  One is via a SQL Agent Job and the other is using a Windows Task Scheduler job.

SQL Agent Job

Since I am a SQL professional I will show you the SQL centric way to accomplish this task.

  1. Create a New SQL Agent Job
  2. I prefer to group my jobs by similar name, so I used !dbatools – Update Module Daily
  3. Once that is done create a New Step for the job
  4. For the command being executed I prefer a step Type of  Operating system (CmdExec)
  5. For the Run As it will default to your SQL Server Agent Service Account (Note: If you use this method your service account will need to be in the Administrators group on the Windows configuration)
  6. Now input the command to be run

7. Create a New Schedule for the job and you are all set

Windows Task Scheduler
  1. Create a New Task
  2. If you prefer this method go ahead and use the same name !dbatools – Update Module Daily
  3. For Tasks we create Triggers.  Our Trigger will be a certain time each day.
  4. Now for the Actions we will have two steps
    1. For the Program/Script section, browse to the  C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    2. For the Arguments section enter  -Command "Update-Module dbatools -force"<a href="https://setrahost.com/~garrybar/wp-content/uploads/2018/05/newtaskaction.png" target="_blank" rel="noopener"><img class="aligncenter wp-image-406 size-medium" src="https://setrahost.com/~garrybar/wp-content/uploads/2018/05/newtaskaction-300x137.png" alt="" width="300" height="137" /></a>
  5. Save your New Task


Now you can either run manually to see the fruits of your labor or wait until the next time it is scheduled.  If everything worked as expected you should have a before and after similar to the screenshots below.




With dbatools rapid CI development process you get a deployment each day or every two days.



Leave a Reply

Your email address will not be published. Required fields are marked *