From e6f3c13d01f836b9929179c6f1bb349a7d7f21c1 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Tue, 28 Oct 2025 03:13:25 +0000 Subject: [PATCH] Stop-DbaService, Start-DbaService - Add PolyBase and Launchpad service type support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #9443 When Enable-DbaAgHadr is run with -Force on servers with PolyBase installed, the service restart would fail because Stop-DbaService and Start-DbaService did not recognize PolyBase and Launchpad as valid service types. Changes: - Stop-DbaService: Added PolyBase and Launchpad to ValidateSet for Type parameter - Stop-DbaService: Enhanced Force logic to automatically include PolyBase services when stopping Engine - Start-DbaService: Added PolyBase and Launchpad to ValidateSet for Type parameter - Update-ServiceStatus: Updated warning message to mention PolyBase dependencies - Updated help documentation in both functions to reflect new service types This brings Stop-DbaService and Start-DbaService in line with Get-DbaService and Restart-DbaService which already supported these service types. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Chrissy LeMaire --- private/functions/Update-ServiceStatus.ps1 | 2 +- public/Start-DbaService.ps1 | 6 ++--- public/Stop-DbaService.ps1 | 30 +++++++++++++--------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/private/functions/Update-ServiceStatus.ps1 b/private/functions/Update-ServiceStatus.ps1 index 10b8ce3032f0..54de5cc00b32 100644 --- a/private/functions/Update-ServiceStatus.ps1 +++ b/private/functions/Update-ServiceStatus.ps1 @@ -210,7 +210,7 @@ process { $target = "$($_.Service.ServiceName) on $($_.Service.ComputerName)" Write-Message -Level Warning -Message "($target) $($_.Service.Message)" -Target $target if ($_.Service.ServiceType -eq 'Engine' -and $_.ServiceExitCode -eq 3) { - Write-Message -Level Warning -Message "($target) Run the command with '-Force' switch to force the restart of a dependent SQL Agent" -Target $target + Write-Message -Level Warning -Message "($target) Run the command with '-Force' switch to force the restart of dependent services (SQL Agent, PolyBase)" -Target $target } } $_.Service | Select-DefaultView -Property ComputerName, ServiceName, InstanceName, ServiceType, State, Status, Message diff --git a/public/Start-DbaService.ps1 b/public/Start-DbaService.ps1 index 8f1bbb396cd8..ad0d3adfd47a 100644 --- a/public/Start-DbaService.ps1 +++ b/public/Start-DbaService.ps1 @@ -4,7 +4,7 @@ function Start-DbaService { Starts SQL Server related services across multiple computers while respecting service dependencies. .DESCRIPTION - Starts SQL Server services (Engine, Agent, Browser, FullText, SSAS, SSIS, SSRS) on one or more computers following proper dependency order. This function handles the complexity of starting services in the correct sequence so you don't have to manually determine which services depend on others. Commonly used after maintenance windows, server reboots, or when troubleshooting stopped services across an environment. + Starts SQL Server services (Engine, Agent, Browser, FullText, SSAS, SSIS, SSRS, PolyBase, Launchpad) on one or more computers following proper dependency order. This function handles the complexity of starting services in the correct sequence so you don't have to manually determine which services depend on others. Commonly used after maintenance windows, server reboots, or when troubleshooting stopped services across an environment. Requires Local Admin rights on destination computer(s). @@ -25,7 +25,7 @@ function Start-DbaService { Credential object used to connect to the computer as a different user. .PARAMETER Type - Filters to specific SQL Server service types rather than starting all services. Valid types: Agent, Browser, Engine, FullText, SSAS, SSIS, SSRS. + Filters to specific SQL Server service types rather than starting all services. Valid types: Agent, Browser, Engine, FullText, SSAS, SSIS, SSRS, PolyBase, Launchpad. Use this when you need to start only specific service types, such as starting just SQL Agent after maintenance or only SSRS services on reporting servers. .PARAMETER Timeout @@ -90,7 +90,7 @@ function Start-DbaService { [string[]]$InstanceName, [Parameter(ParameterSetName = "Server")] [DbaInstanceParameter[]]$SqlInstance, - [ValidateSet("Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS", "SSRS")] + [ValidateSet("Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS", "SSRS", "PolyBase", "Launchpad")] [string[]]$Type, [parameter(ValueFromPipeline, Mandatory, ParameterSetName = "Service")] [Alias("ServiceCollection")] diff --git a/public/Stop-DbaService.ps1 b/public/Stop-DbaService.ps1 index 46882b5c3a07..d4cbfaf0f26a 100644 --- a/public/Stop-DbaService.ps1 +++ b/public/Stop-DbaService.ps1 @@ -4,7 +4,7 @@ function Stop-DbaService { Stops SQL Server-related Windows services with proper dependency handling. .DESCRIPTION - Stops SQL Server services including Database Engine, SQL Agent, Reporting Services, Analysis Services, Integration Services, and other components across one or more computers. Automatically handles service dependencies to prevent dependency conflicts during shutdown operations. + Stops SQL Server services including Database Engine, SQL Agent, Reporting Services, Analysis Services, Integration Services, PolyBase, Launchpad, and other components across one or more computers. Automatically handles service dependencies to prevent dependency conflicts during shutdown operations. Particularly useful for planned maintenance windows, troubleshooting service issues, or preparing servers for patching and reboots. The Force parameter allows stopping dependent services automatically, which is essential when stopping Database Engine services that have SQL Agent dependencies. @@ -29,7 +29,7 @@ function Stop-DbaService { Credential object used to connect to the computer as a different user. .PARAMETER Type - Filters which SQL Server service types to stop. Valid options: Agent, Browser, Engine, FullText, SSAS, SSIS, SSRS. + Filters which SQL Server service types to stop. Valid options: Agent, Browser, Engine, FullText, SSAS, SSIS, SSRS, PolyBase, Launchpad. Use this when you need to stop specific service types across instances, such as stopping all SQL Agent services for patching while keeping Database Engine services running. .PARAMETER Timeout @@ -103,7 +103,7 @@ function Stop-DbaService { [string[]]$InstanceName, [Parameter(ParameterSetName = "Server")] [DbaInstanceParameter[]]$SqlInstance, - [ValidateSet("Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS", "SSRS")] + [ValidateSet("Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS", "SSRS", "PolyBase", "Launchpad")] [string[]]$Type, [parameter(ValueFromPipeline, Mandatory, ParameterSetName = "Service")] [Alias("ServiceCollection")] @@ -133,16 +133,22 @@ function Stop-DbaService { end { $processArray = [array]($processArray | Where-Object { (!$InstanceName -or $_.InstanceName -in $InstanceName) -and (!$Type -or $_.ServiceType -in $Type) }) foreach ($service in $processArray) { - if ($Force -and $service.ServiceType -eq 'Engine' -and !($processArray | Where-Object { $_.ServiceType -eq 'Agent' -and $_.InstanceName -eq $service.InstanceName -and $_.ComputerName -eq $service.ComputerName })) { - #Construct parameters to call Get-DbaService - $serviceParams = @{ - ComputerName = $service.ComputerName - InstanceName = $service.InstanceName - Type = 'Agent' + if ($Force -and $service.ServiceType -eq 'Engine') { + # Add dependent services (Agent, PolyBase) if not already in the array + $dependentTypes = @('Agent', 'PolyBase') + foreach ($depType in $dependentTypes) { + if (!($processArray | Where-Object { $_.ServiceType -eq $depType -and $_.InstanceName -eq $service.InstanceName -and $_.ComputerName -eq $service.ComputerName })) { + #Construct parameters to call Get-DbaService + $serviceParams = @{ + ComputerName = $service.ComputerName + InstanceName = $service.InstanceName + Type = $depType + } + if ($Credential) { $serviceParams.Credential = $Credential } + if ($EnableException) { $serviceParams.EnableException = $EnableException } + $processArray += @(Get-DbaService @serviceParams) + } } - if ($Credential) { $serviceParams.Credential = $Credential } - if ($EnableException) { $serviceParams.EnableException = $EnableException } - $processArray += @(Get-DbaService @serviceParams) } } if ($PSCmdlet.ShouldProcess("$ProcessArray", "Stopping Service")) {