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 to automate uninstalling a SQL Server instance using dbatools. Starting with the following command:

$list = Get-WmiObject -Class Win32_product | Select-DbaObject -Property Name $list.name -cmatch "SQL Server 2019 Database Engine Services".

It returns two entries. My questions:

  • There is only one version of SQL Server on the newly built machine, why are two entries returned?
  • Is the Engine Service the appropriate service to remove in order to remove all the installed features of the instance at once? $list returns a number of SQL Server 2019 components.

Thank you

  • @Charlieface, thank you for your time and response. That link however refers to uninstall from the command line, whereas I am looking to use Powershell/Dbatools. thanks all the same for your help.
    – PTL_SQL
    Feb 11 at 20:45
  • What's the difference? You can call setup.exe from Powershell also. DbaTools doesn't even seem to offer an Uninstall cmdlet. Feb 11 at 20:53
  • Hi @Charlieface , thanks again for your time. I found out that the powershell module sqlserverdsc does uninstall, so I am currently trying that out. Much appreciated.
    – PTL_SQL
    Feb 19 at 10:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.