Set-ServiceBinaryPath
SYNOPSIS
Sets the binary path for a service to a specified value.
Author: Will Schroeder (@harmj0y), Matthew Graeber (@mattifestation)
License: BSD 3-Clause
Required Dependencies: PSReflect
SYNTAX
DESCRIPTION
Takes a service Name or a ServiceProcess.ServiceController on the pipeline and first opens up a service handle to the service with ConfigControl access using the GetServiceHandle Win32 API call. ChangeServiceConfig is then used to set the binary path (lpBinaryPathName/binPath) to the string value specified by binPath, and the handle is closed off.
Takes one or more ServiceProcess.ServiceController objects on the pipeline and adds a Dacl field to each object. It does this by opening a handle with ReadControl for the service with using the GetServiceHandle Win32 API call and then uses QueryServiceObjectSecurity to retrieve a copy of the security descriptor for the service.
EXAMPLES
-------------------------- EXAMPLE 1 --------------------------
Sets the binary path for 'VulnSvc' to be a command to add a user.
-------------------------- EXAMPLE 2 --------------------------
Sets the binary path for 'VulnSvc' to be a command to add a user.
PARAMETERS
-Name
An array of one or more service names to set the binary path for. Required.
Type: String[]
Parameter Sets: (All)
Aliases: ServiceName
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
-Path
The new binary path (lpBinaryPathName) to set for the specified service. Required.
Type: String
Parameter Sets: (All)
Aliases: BinaryPath, binPath
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
OUTPUTS
- System.Boolean
$True if configuration succeeds, $False otherwise.
RELATED LINKS
https://msdn.microsoft.com/en-us/library/windows/desktop/ms681987(v=vs.85).aspx