Rootvalue when using
Merge-Scriptor the Entry Point when packaging through Visual Studio.
OnStartfunction will be called when the service is started. You should not block the execution of this function. If you need to start a background process, consider using
Start-Job. Once the function returns, the service will be listed as running in Service Control Manager.
OnStopfunction will be called when the Service Control Manager attempts to stop the service. You can do any clean up of resources for your service in this function. This would be a good place to stop any jobs using
$CanStopvariable to either
$false. If set to
$false, the service cannot be stopped by the Service Control Manager.
$ProcessArgsvariable. You can access the service startup parameters by accessing the
--installto the service's executable. Install will not start the service so use Start-Service to start your new service by the name you provided.
--uninstallflag for your service's executable. It will also take care of stopping the service.
New-Servicecmdlet to install a service for PowerShell 7.
Remove-Servicecmdlet to uninstall a service built for PowerShell 7.