Manage ServiceControl instances via PowerShell

For general information about ServiceControl Powershell, including troubleshooting and licensing guidance, see Managing ServiceControl via PowerShell.

ServiceControl instance Cmdlets and Aliases

The following cmdlets and aliases are provided by the ServiceControl Management PowerShell module for the management of ServiceControl instances.



All of the cmdlets have local help which can be accessed via the standard PowerShell help command

Get-Help Get-ServiceControlInstances

Adding an instance

New-ServiceControlInstance -Name Test.ServiceControl -InstallPath C:\ServiceControl\Bin -DBPath C:\ServiceControl\DB -LogPath C:\ServiceControl\Logs -Port 33334 -Transport MSMQ -ErrorQueue error1 -AuditQueue audit1

There are additional parameters available to set additional configuration options such as forwarding queues, the transport connection string or hostname.

Removing an instance

The following commands show how to remove a ServiceControl instance(s). To List existing instances of the ServiceControl service use Get-ServiceControlInstances.

Remove the instance that was created in the Add sample and delete the database and logs:

Remove-ServiceControlInstance -Name Test.ServiceControl -RemoveDB -RemoveLogs

Remove all ServiceControl instance created in the Add sample and delete the database and logs for each one:

Get-ServiceControlInstances | Remove-ServiceControlInstance -RemoveDB -RemoveLogs

There are additional parameters available to set additional configuration options such as forwarding queues, the transport connection string or host name.

Upgrading an instance

The following command will list the ServiceControl instances current installed and their version number.

Get-ServiceControlInstances | Select Name, Version

To upgrade and instance to the latest version of the binaries run.

Invoke-ServiceControlInstanceUpgrade -Name <Instance To upgrade>

The upgrade will stop the service if it is running. Additional parameters for Invoke-ServiceControlInstanceUpgrade may be required. The configuration file of the existing version is examined prior to determine if all the required settings are present. If a configuration setting is missing then the cmdlet will throw an error indicating the required additional parameter.

Building an unattended install file

Since ServiceControl 1.7 the installation executable has a MSI command line argument to enable the installation of a ServiceControl service instance during installation. This is intended to assist with unattended installation

The MSI command line argument requires an XML file which detail the instance options. The file can be produced by running the following cmdlet or by manually creating the XML file.

New-ServiceControlUnattendedFile -OutputFile c:\temp\unattended.xml -Name Test -InstallPath c:\servicecontrol\test\bin -DBPath c:\servicecontrol\test\db -LogPath c:\servicecontrol\test\logs -Port 33335 -ErrorQueue error-test -AuditQueue audit-test -ErrorLogQueue errorlog-test -AuditLogQueue auditlog-test -Transport MSMQ -ForwardAuditMessages $false -ForwardErrorMessages $false

This sample produces the following file

<?xml version="1.0"?>
The settings contained in an unattended installation files are version specific. The file contents will be validated when used and if a required setting is missing an error will be logged. To correct this regenerate the XML file using the New-ServiceControlUnattendedFile cmdlet.

Testing an unattended install file

There New-ServiceControlInstanceFromUnattendedFile cmdlet creates an instance from the unattended file. The service account details can optionally be provided. If no service account details are specified the LocalSystem account is used

New-ServiceControlInstanceFromUnattendedFile -UnattendFile c:\temp\unattended.xml -ServiceAccount MyServiceAccount -ServiceAccountPassword MyPassword
Neither the unattended file method or the New-ServiceControlInstance cover all the configuration settings that are available to ServiceControl. To set additonal options refer to Customizing ServiceControl configuration. A scripted method of adding additional settings is detailed in Installing ServiceControl Silently.

Last modified