Register PodeService - mdaneri/Pode GitHub Wiki
Registers a new Pode-based PowerShell worker as a service on Windows, Linux, or macOS.
Register-PodeService [-Name] <String> [[-Description] <String>] [[-DisplayName] <String>]
[[-StartupType] <String>] [[-SecurityDescriptorSddl] <String>] [[-ParameterString] <String>]
[-LogServicePodeHost] [[-ShutdownWaitTimeMs] <Int32>] [[-StartMaxRetryCount] <Int32>]
[[-StartRetryDelayMs] <Int32>] [[-WindowsUser] <String>] [[-LinuxUser] <String>] [-Start] [-Agent]
[[-Password] <SecureString>] [[-SettingsPath] <String>] [[-LogPath] <String>] [[-LogLevel] <String>]
[[-LogMaxFileSize] <Int64>] [[-ConfigFile] <String>] [-IgnoreServerConfig]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
The `Register-PodeService` function configures and registers a Pode-based service that runs a PowerShell worker across multiple platforms (Windows, Linux, macOS). It creates the service with parameters such as paths to the worker script, log files, and service-specific settings. A `srvsettings.json` configuration file is generated, and the service can be optionally started after registration.
Register-PodeService -Name "PodeExampleService" -Description "Example Pode Service" -ParameterString "-Verbose"
This example registers a Pode service named "PodeExampleService" with verbose logging enabled.
Create an Agent instead of a Daemon on macOS (macOS only).
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies a custom configuration file instead of using the default `server.psd1`.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 17
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseA brief description of the service. Defaults to "This is a Pode service."
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: This is a Pode service.
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the display name for the service (Windows only). Defaults to "Pode Service($Name)".
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: "Pode Service($Name)"
Accept pipeline input: False
Accept wildcard characters: FalsePrevents the server from loading settings from the server.psd1 configuration file.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the username under which the service will run on Linux. Defaults to the current user if not provided.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 11
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the log verbosity level. Valid values are 'Debug', 'Info', 'Warn', 'Error', or 'Critical'. Defaults to 'Info'.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 15
Default value: Info
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the maximum size of the log file in bytes. Defaults to 10 MB (10,485,760 bytes).
Type: Int64
Parameter Sets: (All)
Aliases:
Required: False
Position: 16
Default value: 10485760
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the path for the service log files. If not provided, a default log directory is used.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 14
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseEnables logging for the Pode service host. If not provided, the service runs in quiet mode.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the name of the service to be registered. This is a required parameter.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseAny additional parameters to pass to the worker script when the service is run. Defaults to an empty string.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseA secure password for the service account (Windows only). If omitted, the service account defaults to 'NT AUTHORITY\SYSTEM'.
Type: SecureString
Parameter Sets: (All)
Aliases:
Required: False
Position: 12
Default value: None
Accept pipeline input: False
Accept wildcard characters: False{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseA security descriptor in SDDL format, specifying the permissions for the service (Windows only).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the directory to store the service configuration file (`<name>_svcsettings.json`). If not provided, a default directory is used.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 13
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseMaximum time in milliseconds to wait for the service to shut down gracefully before forcing termination. Defaults to 30,000 milliseconds (30 seconds).
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: 30000
Accept pipeline input: False
Accept wildcard characters: FalseA switch to start the service immediately after registration.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThe maximum number of retries to start the PowerShell process before giving up. Default is 3 retries.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: 3
Accept pipeline input: False
Accept wildcard characters: FalseThe delay (in milliseconds) between retry attempts to start the PowerShell process. Default is 5,000 milliseconds (5 seconds).
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 9
Default value: 5000
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the startup type of the service ('Automatic' or 'Manual'). Defaults to 'Automatic'.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: Automatic
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the username under which the service will run on Windows. Defaults to the current user if not provided.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
- Supports cross-platform service registration on Windows, Linux, and macOS.
- Generates a `srvsettings.json` file with service-specific configurations.
- Automatically starts the service using the `-Start` switch after registration.
- Dynamically obtains the PowerShell executable path for compatibility across platforms.