Skip to content

Add documentation for new -SecurityDescriptorSddl parameter of New-Service #4735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions reference/7/Microsoft.PowerShell.Management/New-Service.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Creates a new Windows service.

```
New-Service [-Name] <String> [-BinaryPathName] <String> [-DisplayName <String>] [-Description <String>]
[-StartupType <ServiceStartupType>] [-Credential <PSCredential>] [-DependsOn <String[]>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-SecurityDescriptorSddl <String>] [-StartupType <ServiceStartupType>] [-Credential <PSCredential>]
[-DependsOn <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -62,6 +62,18 @@ Status : OK
This command uses **Get-WmiObject** to get the **Win32_Service** object for the new service.
This object includes the start mode and the service description.

### Example 4: Set the SecurityDescriptor of a service when creating.

This example adds the **SecurityDescriptor** of the service being created.

```powershell
$SDDLToSet = "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;SU)"
New-Service -Name "TestService" -BinaryPathName "C:\WINDOWS\System32\svchost.exe -k netsvcs" -DependsOn NetLogon -DisplayName "Test Service" -StartupType Manual -Description "This is a test service." -SecurityDescriptorSddl $SDDLToSet
```

The **SecurityDescriptor** is stored in the `$SDDLToSet` variable. The **SecurityDescriptorSddl** parameter uses
`$SDDLToSet` to set the **SecurityDescriptor** of the new service.

## PARAMETERS

### -BinaryPathName
Expand Down Expand Up @@ -194,6 +206,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -SecurityDescriptorSddl

Specifies the **SecurityDescriptor** for the service in **Sddl** format.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm

Prompts you for confirmation before running the cmdlet.
Expand Down Expand Up @@ -264,5 +292,3 @@ This cmdlet returns an object that represents the new service.
[Suspend-Service](Suspend-Service.md)

[Remove-Service](Remove-Service.md)