Skip to content

Add maintenance mode cmdlets to the PowerShell module - #6166

Draft
npink42 wants to merge 3 commits into
masterfrom
PS-ServiceControl-Maintenance-Mode
Draft

npink42 wants to merge 3 commits into
masterfrom
PS-ServiceControl-Maintenance-Mode

Conversation

@npink42

@npink42 npink42 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Draft pr. I will add detail if testing works out.

Adds Enable- and Disable-ServiceControlMaintenanceMode and the audit equivalents, with sc-maintenance-on/off and audit-maintenance-on/off aliases. Each cmdlet stops the service, updates the maintenance mode setting, and starts the service.
@npink42
npink42 marked this pull request as draft November 20, 2026 13:13
Start- stops the service, enables maintenance mode, and starts the service. Stop- stops the service and clears maintenance mode, leaving the service stopped, as ServiceControl Management does. Aliases become sc-maintenance-start/stop and audit-maintenance-start/stop.
Each cmdlet now lives in the ServiceControlInstances or AuditInstances folder and carries its own parameter, admin check, and instance lookup.
@soujay soujay modified the milestone: NextMajor Nov 20, 2026
Comment on lines +44 to +47
New-Alias -Value Start-ServiceControlMaintenanceMode -Name sc-maintenance-start
New-Alias -Value Stop-ServiceControlMaintenanceMode -Name sc-maintenance-stop
New-Alias -Value Start-ServiceControlAuditMaintenanceMode -Name audit-maintenance-start
New-Alias -Value Stop-ServiceControlAuditMaintenanceMode -Name audit-maintenance-stop

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
New-Alias -Value Start-ServiceControlMaintenanceMode -Name sc-maintenance-start
New-Alias -Value Stop-ServiceControlMaintenanceMode -Name sc-maintenance-stop
New-Alias -Value Start-ServiceControlAuditMaintenanceMode -Name audit-maintenance-start
New-Alias -Value Stop-ServiceControlAuditMaintenanceMode -Name audit-maintenance-stop
New-Alias -Value Start-ServiceControlMaintenanceMode -Name sc-startmaintenance
New-Alias -Value Stop-ServiceControlMaintenanceMode -Name sc-stopmaintenance
New-Alias -Value Start-ServiceControlAuditMaintenanceMode -Name audit-startmaintenance
New-Alias -Value Stop-ServiceControlAuditMaintenanceMode -Name audit-stopmaintenance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether mode even adds any value to the full command name. We do have docs that say Maintenance Mode, and the UI says maintenance mode, but it's just extra letters to potentially type in this scenario, and we removed it from the aliases. Either way is probably fine; it's just something to consider the trade-offs of.

<dev:version />
</command:details>
<maml:description>
<maml:para>Stops the ServiceControl service and removes the maintenance mode setting from its configuration file. The service stays stopped; start it normally to resume ingesting error messages. Requires an elevated session. Alias: sc-maintenance-stop</maml:para>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<maml:para>Stops the ServiceControl service and removes the maintenance mode setting from its configuration file. The service stays stopped; start it normally to resume ingesting error messages. Requires an elevated session. Alias: sc-maintenance-stop</maml:para>
<maml:para>Stops the ServiceControl service and removes the maintenance mode setting from its configuration file. The service stays stopped; start it normally to resume ingesting error messages. Requires an elevated session. Alias: sc-stopmaintenance</maml:para>

<dev:version />
</command:details>
<maml:description>
<maml:para>Stops the ServiceControl service, writes the maintenance mode setting to its configuration file, and starts the service again. In maintenance mode the instance does not ingest error messages and its RavenDB database stays available. Run Stop-ServiceControlMaintenanceMode to clear the setting and stop the service. Requires an elevated session. Alias: sc-maintenance-start</maml:para>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<maml:para>Stops the ServiceControl service, writes the maintenance mode setting to its configuration file, and starts the service again. In maintenance mode the instance does not ingest error messages and its RavenDB database stays available. Run Stop-ServiceControlMaintenanceMode to clear the setting and stop the service. Requires an elevated session. Alias: sc-maintenance-start</maml:para>
<maml:para>Stops the ServiceControl service, writes the maintenance mode setting to its configuration file, and starts the service again. In maintenance mode the instance does not ingest error messages and its RavenDB database stays available. Run Stop-ServiceControlMaintenanceMode to clear the setting and stop the service. Requires an elevated session. Alias: sc-startmaintenance</maml:para>

{
[ValidateNotNullOrEmpty]
[Parameter(Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, Position = 0, HelpMessage = "Specify the ServiceControl Audit instance name")]
public string[] Name { get; set; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably just be a single string and not an array


protected override void ProcessRecord()
{
foreach (var name in Name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this foreach can go away

</maml:description>
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<maml:name>String[]</maml:name>
<maml:name>String</maml:name>

<maml:description>
<maml:para>Name of the ServiceControl Audit Service. This corresponds to the Windows Service Name for the service not the Display Name.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>
<command:parameterValue required="true" variableLength="true">String</command:parameterValue>

</maml:description>
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<maml:name>String[]</maml:name>
<maml:name>String</maml:name>

</maml:description>
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<maml:name>String[]</maml:name>
<maml:name>String</maml:name>

<maml:description>
<maml:para>Name of the ServiceControl Service. This corresponds to the Windows Service Name for the service not the Display Name.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<command:parameterValue required="true" variableLength="true">String[]</command:parameterValue>
<command:parameterValue required="true" variableLength="true">String</command:parameterValue>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants