@@ -17,8 +17,8 @@ Creates a new Windows service.
17
17
18
18
```
19
19
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>]
22
22
```
23
23
24
24
## DESCRIPTION
@@ -62,6 +62,18 @@ Status : OK
62
62
This command uses ** Get-WmiObject** to get the ** Win32_Service** object for the new service.
63
63
This object includes the start mode and the service description.
64
64
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
+
65
77
## PARAMETERS
66
78
67
79
### -BinaryPathName
@@ -194,6 +206,22 @@ Accept pipeline input: False
194
206
Accept wildcard characters : False
195
207
` ` `
196
208
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
+
197
225
### -Confirm
198
226
199
227
Prompts you for confirmation before running the cmdlet.
@@ -264,5 +292,3 @@ This cmdlet returns an object that represents the new service.
264
292
[Suspend-Service](Suspend-Service.md)
265
293
266
294
[Remove-Service](Remove-Service.md)
267
-
268
-
0 commit comments