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.
- Create a New SQL Agent Job
- I prefer to group my jobs by similar name, so I used !dbatools – Update Module Daily
- Once that is done create a New Step for the job
- For the command being executed I prefer a step Type of Operating system (CmdExec)
- 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)
- Now input the command to be run
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Update-Module dbatools -force"
Windows Task Scheduler
- Create a New Task
- If you prefer this method go ahead and use the same name !dbatools – Update Module Daily
- For Tasks we create Triggers. Our Trigger will be a certain time each day.
- Now for the Actions we will have two steps
- For the Program/Script section, browse to the C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
- 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>
- 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.