Skip to content

Servy PowerShell Module

Akram El Assas edited this page Jan 16, 2026 · 113 revisions

Table of Contents

Introduction

The Servy PowerShell Module Servy.psm1 allows you to manage Windows services easily using PowerShell. You can install, start, stop, restart, export/import configurations, check service status, show help, display the version, and uninstall services.

Once you install Servy, the Servy PowerShell module is available at:

%ProgramFiles%\Servy\Servy.psm1

The PowerShell module is compatible with PowerShell 2.0+, Windows 7+ and Windows Server 2008+. If Servy is installed, the module will automatically locate the CLI executable. For the portable version of Servy, place the module Servy.psm1 in the same folder as servy-cli.exe The module will automatically detect and use the local executable.

You can find detailed examples of how to use it here.

Important: If you face any issues with the PowerShell module in automated or non-interactive environments (e.g., CI/CD, Ansible, WinRM), use -Quiet option to suppress interactive output such as spinners or loading animations.

Installation

Import the module in your PowerShell session:

Import-Module "C:\Program Files\Servy\Servy.psm1" -Force

Display the version:

Show-ServyVersion -Quiet

Display help:

Show-ServyHelp

Usage Examples

Install a New Service

Install-ServyService `
  -Quiet `
  -Name "WexflowServer" `
  -Description "Wexflow Workflow Engine" `
  -Path "C:\Program Files\dotnet\dotnet.exe" `
  -StartupDir "C:\Program Files\Wexflow Server\Wexflow.Server" `
  -Params "Wexflow.Server.dll" `
  -StartupType "Automatic"

Export Service Configuration

Export-ServyServiceConfig `
  -Quiet `
  -Name "WexflowServer" `
  -ConfigFileType "xml" `
  -Path "C:\WexflowServer.xml"

Export-ServyServiceConfig `
  -Quiet `
  -Name "WexflowServer" `
  -ConfigFileType "json" `
  -Path "C:\WexflowServer.json"

Import Service Configuration

Import-ServyServiceConfig `
  -Quiet `
  -ConfigFileType "xml" `
  -Path "C:\WexflowServer.xml" `
  -Install

Import-ServyServiceConfig `
  -Quiet `
  -ConfigFileType "json" `
  -Path "C:\WexflowServer.json"

Start, Stop, Restart, and Check Status

Start-ServyService -Quiet -Name "WexflowServer"
Get-ServyServiceStatus -Quiet -Name "WexflowServer"
Stop-ServyService -Quiet -Name "WexflowServer"
Restart-ServyService -Quiet -Name "WexflowServer"

Uninstall a Service

Uninstall-ServyService -Quiet -Name "WexflowServer"

Cmdlets Reference

Cmdlet Parameters Description
Install-ServyService -Name (string, required)
-Path (string, required)
-DisplayName (string, optional)
-Description (string, optional)
-StartupDir (string, optional)
-Params (string, optional)
-StartupType (string, optional: Automatic, AutomaticDelayedStart, Manual, Disabled)
-Priority (string, optional: Idle, BelowNormal, Normal, AboveNormal, High, RealTime)
-Stdout (string, optional)
-Stderr (string, optional)
-StartTimeout (string, optional)
-StopTimeout (string, optional)
-EnableSizeRotation (switch, optional)
-RotationSize (string, optional)
-EnableDateRotation (switch, optional)
-DateRotationType (string, optional: Daily, Weekly, Monthly)
-MaxRotations (string, optional)
-EnableHealth (switch, optional)
-HeartbeatInterval (string, optional)
-MaxFailedChecks (string, optional)
-RecoveryAction (string, optional: None, RestartService, RestartProcess, RestartComputer)
-MaxRestartAttempts (string, optional)
-FailureProgramPath (string, optional)
-FailureProgramStartupDir (string, optional)
-FailureProgramParams (string, optional)
-Env (string, optional)
-Deps (string, optional)
-User (string, optional)
-Password (string, optional)
-PreLaunchPath (string, optional)
-PreLaunchStartupDir (string, optional)
-PreLaunchParams (string, optional)
-PreLaunchEnv (string, optional)
-PreLaunchStdout (string, optional)
-PreLaunchStderr (string, optional)
-PreLaunchTimeout (string, optional)
-PreLaunchRetryAttempts (string, optional)
-PreLaunchIgnoreFailure (switch, optional)
-PostLaunchPath (string, optional)
-PostLaunchStartupDir (string, optional)
-PostLaunchParams (string, optional)
-EnableDebugLogs (switch, optional)
-Quiet (switch, optional)
Installs a new Windows service with advanced configuration.

Wraps the Servy CLI install command to turn any executable into a managed Windows service. It supports complex lifecycle management, logging, and self-healing features.

Key Features:
Logging: Redirect standard output and error to files with automatic rotation by size (MB) or date (Daily/Weekly/Monthly).
Health Monitoring: Actively monitors the process; if it fails a set number of heartbeats, Servy can automatically restart the service, the process, or the entire computer.
Lifecycle Hooks: Execute scripts or binaries before (PreLaunch) or after (PostLaunch) the main service process. This is ideal for cleaning temp files or initializing databases.
Security: Set specific environment variables using Key=Value; syntax and run the service under a specific user account.

Examples:
Basic: Install-ServyService -Name "MyApp" -Path "C:\App\app.exe"
With Logging: Install-ServyService -Name "MyApp" -Path "C:\App\app.exe" -Stdout "C:\Logs\out.log" -EnableSizeRotation -RotationSize 10
With Recovery: Install-ServyService -Name "MyApp" -Path "C:\App\app.exe" -EnableHealth -MaxFailedChecks 3 -RecoveryAction RestartService
With Env Vars: Install-ServyService -Name "MyApp" -Path "C:\App\app.exe" -Env "PORT=8080;NODE_ENV=production"
Uninstall-ServyService -Name (string, required)
-Quiet (switch, optional)
Uninstalls a Windows service by name.
Removes the service from both Windows Service Control Manager and the Servy database.
Start-ServyService -Name (string, required)
-Quiet (switch, optional)
Starts a Windows service.
If PreLaunch parameters are configured, they are executed before the service starts.
Stop-ServyService -Name (string, required)
-Quiet (switch, optional)
Stops a Windows service.
Gracefully terminates the service process based on the configured StopTimeout.
Restart-ServyService -Name (string, required)
-Quiet (switch, optional)
Restarts a Windows service.
Sequentially performs a stop and then a start operation.
Get-ServyServiceStatus -Name (string, required)
-Quiet (switch, optional)
Gets the current status of a Windows service.
Possible results: Stopped, StartPending, StopPending, Running, ContinuePending, PausePending, Paused.
Export-ServyServiceConfig -Name (string, required)
-ConfigFileType (string, required: xml, json)
-Path (string, required)
-Quiet (switch, optional)
Exports the configuration of a service to a file.
Allows backing up service settings to xml or json formats.
Import-ServyServiceConfig -ConfigFileType (string, required: xml, json)
-Path (string, required)
-Install (switch, optional)
-Quiet (switch, optional)
Imports a service configuration from a file into Servy's database.
If the -Install switch is provided, the service is automatically registered with Windows after import.
Show-ServyHelp -Command (string, optional)
-Quiet (switch, optional)
Displays help information for all Servy CLI commands.
Can provide detailed help for a specific command if the -Command parameter is used.
Show-ServyVersion -Quiet (switch, optional) Displays the current version of the Servy CLI module.
Verifies the version of the underlying servy-cli.exe.

References

Clone this wiki locally