Skip to content

Commit 996b7e6

Browse files
Stop-DbaService, Start-DbaService - Add PolyBase and Launchpad service type support (#9879)
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
1 parent df08d29 commit 996b7e6

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

private/functions/Update-ServiceStatus.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ process {
210210
$target = "$($_.Service.ServiceName) on $($_.Service.ComputerName)"
211211
Write-Message -Level Warning -Message "($target) $($_.Service.Message)" -Target $target
212212
if ($_.Service.ServiceType -eq 'Engine' -and $_.ServiceExitCode -eq 3) {
213-
Write-Message -Level Warning -Message "($target) Run the command with '-Force' switch to force the restart of a dependent SQL Agent" -Target $target
213+
Write-Message -Level Warning -Message "($target) Run the command with '-Force' switch to force the restart of dependent services (SQL Agent, PolyBase)" -Target $target
214214
}
215215
}
216216
$_.Service | Select-DefaultView -Property ComputerName, ServiceName, InstanceName, ServiceType, State, Status, Message

public/Start-DbaService.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Start-DbaService {
44
Starts SQL Server related services across multiple computers while respecting service dependencies.
55
66
.DESCRIPTION
7-
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.
7+
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.
88
99
Requires Local Admin rights on destination computer(s).
1010
@@ -25,7 +25,7 @@ function Start-DbaService {
2525
Credential object used to connect to the computer as a different user.
2626
2727
.PARAMETER Type
28-
Filters to specific SQL Server service types rather than starting all services. Valid types: Agent, Browser, Engine, FullText, SSAS, SSIS, SSRS.
28+
Filters to specific SQL Server service types rather than starting all services. Valid types: Agent, Browser, Engine, FullText, SSAS, SSIS, SSRS, PolyBase, Launchpad.
2929
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.
3030
3131
.PARAMETER Timeout
@@ -90,7 +90,7 @@ function Start-DbaService {
9090
[string[]]$InstanceName,
9191
[Parameter(ParameterSetName = "Server")]
9292
[DbaInstanceParameter[]]$SqlInstance,
93-
[ValidateSet("Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS", "SSRS")]
93+
[ValidateSet("Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS", "SSRS", "PolyBase", "Launchpad")]
9494
[string[]]$Type,
9595
[parameter(ValueFromPipeline, Mandatory, ParameterSetName = "Service")]
9696
[Alias("ServiceCollection")]

public/Stop-DbaService.ps1

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Stop-DbaService {
44
Stops SQL Server-related Windows services with proper dependency handling.
55
66
.DESCRIPTION
7-
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.
7+
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.
88
99
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.
1010
@@ -29,7 +29,7 @@ function Stop-DbaService {
2929
Credential object used to connect to the computer as a different user.
3030
3131
.PARAMETER Type
32-
Filters which SQL Server service types to stop. Valid options: Agent, Browser, Engine, FullText, SSAS, SSIS, SSRS.
32+
Filters which SQL Server service types to stop. Valid options: Agent, Browser, Engine, FullText, SSAS, SSIS, SSRS, PolyBase, Launchpad.
3333
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.
3434
3535
.PARAMETER Timeout
@@ -103,7 +103,7 @@ function Stop-DbaService {
103103
[string[]]$InstanceName,
104104
[Parameter(ParameterSetName = "Server")]
105105
[DbaInstanceParameter[]]$SqlInstance,
106-
[ValidateSet("Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS", "SSRS")]
106+
[ValidateSet("Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS", "SSRS", "PolyBase", "Launchpad")]
107107
[string[]]$Type,
108108
[parameter(ValueFromPipeline, Mandatory, ParameterSetName = "Service")]
109109
[Alias("ServiceCollection")]
@@ -133,16 +133,22 @@ function Stop-DbaService {
133133
end {
134134
$processArray = [array]($processArray | Where-Object { (!$InstanceName -or $_.InstanceName -in $InstanceName) -and (!$Type -or $_.ServiceType -in $Type) })
135135
foreach ($service in $processArray) {
136-
if ($Force -and $service.ServiceType -eq 'Engine' -and !($processArray | Where-Object { $_.ServiceType -eq 'Agent' -and $_.InstanceName -eq $service.InstanceName -and $_.ComputerName -eq $service.ComputerName })) {
137-
#Construct parameters to call Get-DbaService
138-
$serviceParams = @{
139-
ComputerName = $service.ComputerName
140-
InstanceName = $service.InstanceName
141-
Type = 'Agent'
136+
if ($Force -and $service.ServiceType -eq 'Engine') {
137+
# Add dependent services (Agent, PolyBase) if not already in the array
138+
$dependentTypes = @('Agent', 'PolyBase')
139+
foreach ($depType in $dependentTypes) {
140+
if (!($processArray | Where-Object { $_.ServiceType -eq $depType -and $_.InstanceName -eq $service.InstanceName -and $_.ComputerName -eq $service.ComputerName })) {
141+
#Construct parameters to call Get-DbaService
142+
$serviceParams = @{
143+
ComputerName = $service.ComputerName
144+
InstanceName = $service.InstanceName
145+
Type = $depType
146+
}
147+
if ($Credential) { $serviceParams.Credential = $Credential }
148+
if ($EnableException) { $serviceParams.EnableException = $EnableException }
149+
$processArray += @(Get-DbaService @serviceParams)
150+
}
142151
}
143-
if ($Credential) { $serviceParams.Credential = $Credential }
144-
if ($EnableException) { $serviceParams.EnableException = $EnableException }
145-
$processArray += @(Get-DbaService @serviceParams)
146152
}
147153
}
148154
if ($PSCmdlet.ShouldProcess("$ProcessArray", "Stopping Service")) {

0 commit comments

Comments
 (0)