Skip to content

Commit 6ace6db

Browse files
kvprasoonsdwheeler
authored andcommitted
add documentation for new ### -SecurityDescriptorSddl parameter (#4735)
1 parent 44b5aa5 commit 6ace6db

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

reference/7/Microsoft.PowerShell.Management/New-Service.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Creates a new Windows service.
1717

1818
```
1919
New-Service [-Name] <String> [-BinaryPathName] <String> [-DisplayName <String>] [-Description <String>]
20-
[-StartupType <ServiceStartupType>] [-Credential <PSCredential>] [-DependsOn <String[]>] [-WhatIf] [-Confirm]
21-
[<CommonParameters>]
20+
[-SecurityDescriptorSddl <String>] [-StartupType <ServiceStartupType>] [-Credential <PSCredential>]
21+
[-DependsOn <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
2222
```
2323

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

65+
### Example 4: Set the SecurityDescriptor of a service when creating.
66+
67+
This example adds the **SecurityDescriptor** of the service being created.
68+
69+
```powershell
70+
$SDDLToSet = "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;SU)"
71+
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
72+
```
73+
74+
The **SecurityDescriptor** is stored in the `$SDDLToSet` variable. The **SecurityDescriptorSddl** parameter uses
75+
`$SDDLToSet` to set the **SecurityDescriptor** of the new service.
76+
6577
## PARAMETERS
6678

6779
### -BinaryPathName
@@ -194,6 +206,22 @@ Accept pipeline input: False
194206
Accept wildcard characters: False
195207
```
196208
209+
### -SecurityDescriptorSddl
210+
211+
Specifies the **SecurityDescriptor** for the service in **Sddl** format.
212+
213+
```yaml
214+
Type: String
215+
Parameter Sets: (All)
216+
Aliases:
217+
218+
Required: False
219+
Position: Named
220+
Default value: None
221+
Accept pipeline input: False
222+
Accept wildcard characters: False
223+
```
224+
197225
### -Confirm
198226
199227
Prompts you for confirmation before running the cmdlet.
@@ -264,5 +292,3 @@ This cmdlet returns an object that represents the new service.
264292
[Suspend-Service](Suspend-Service.md)
265293
266294
[Remove-Service](Remove-Service.md)
267-
268-

0 commit comments

Comments
 (0)