Skip to content

Commit 65cb89f

Browse files
committed
Fix help file and cmdToExe split
1 parent b89c43b commit 65cb89f

File tree

2 files changed

+113
-25
lines changed

2 files changed

+113
-25
lines changed

src/Compute/Compute/Extension/CustomScript/SetAzureVMCustomScriptExtensionCommand.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,14 @@ public override void ExecuteCmdlet()
328328
this.FileUri = (this.FileUri == null || !this.FileUri.Any()) ? this.InputObject.Uri : this.FileUri;
329329

330330
string cmdToExe = this.InputObject.CommandToExecute;
331-
string cmdToExeFinal = cmdToExe.Substring(cmdToExe.IndexOf("-file ") + 6);
332-
string[] splits = cmdToExeFinal.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
333-
this.Run = string.IsNullOrEmpty(this.Run) ? splits[0] : this.Run;
334-
this.Argument = string.IsNullOrEmpty(this.Argument) ? string.Join(" ", splits.Skip(1)) : this.Argument;
331+
int startIndexFile = cmdToExe.IndexOf("-file ");
332+
if (startIndexFile > 0)
333+
{
334+
string cmdToExeFinal = cmdToExe.Substring(startIndexFile + 6);
335+
string[] splits = cmdToExeFinal.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
336+
this.Run = string.IsNullOrEmpty(this.Run) ? splits[0] : this.Run;
337+
this.Argument = string.IsNullOrEmpty(this.Argument) ? string.Join(" ", splits.Skip(1)) : this.Argument;
338+
}
335339
}
336340

337341
if (!string.IsNullOrEmpty(this.ResourceId))

src/Compute/Compute/help/Set-AzVMCustomScriptExtension.md

Lines changed: 105 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Adds a custom script extension to a virtual machine.
1515

1616
### ByNameWithContainerAndFileNamesParameterSet (Default)
1717
```
18-
Set-AzVMCustomScriptExtension [-ResourceGroupName] <String> -VMName <String> [-Name] <String>
18+
Set-AzVMCustomScriptExtension [-ResourceGroupName] <String> -VMName <String> [[-Name] <String>]
1919
-ContainerName <String> -FileName <String[]> [-StorageAccountName <String>] [-StorageEndpointSuffix <String>]
2020
[-StorageAccountKey <String>] [-Run <String>] [-Argument <String>] [-SecureExecution]
2121
[-TypeHandlerVersion <String>] [-Location <String>] [-DisableAutoUpgradeMinorVersion] [-ForceRerun <String>]
@@ -24,7 +24,7 @@ Set-AzVMCustomScriptExtension [-ResourceGroupName] <String> -VMName <String> [-N
2424

2525
### ByNameWithFileUriParameterSet
2626
```
27-
Set-AzVMCustomScriptExtension [-ResourceGroupName] <String> -VMName <String> [-Name] <String>
27+
Set-AzVMCustomScriptExtension [-ResourceGroupName] <String> -VMName <String> [[-Name] <String>]
2828
[-FileUri <String[]>] [-Run <String>] [-Argument <String>] [-SecureExecution] [-TypeHandlerVersion <String>]
2929
[-Location <String>] [-DisableAutoUpgradeMinorVersion] [-ForceRerun <String>]
3030
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
@@ -107,7 +107,7 @@ Aliases:
107107
Required: False
108108
Position: Named
109109
Default value: None
110-
Accept pipeline input: False
110+
Accept pipeline input: True (ByPropertyName)
111111
Accept wildcard characters: False
112112
```
113113
@@ -116,13 +116,25 @@ Specifies the name of the Azure storage container where this cmdlet stores the s
116116
117117
```yaml
118118
Type: System.String
119-
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet, ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
119+
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet
120120
Aliases:
121121

122122
Required: True
123123
Position: Named
124124
Default value: None
125-
Accept pipeline input: False
125+
Accept pipeline input: True (ByPropertyName)
126+
Accept wildcard characters: False
127+
```
128+
129+
```yaml
130+
Type: System.String
131+
Parameter Sets: ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
132+
Aliases:
133+
134+
Required: True
135+
Position: Named
136+
Default value: None
137+
Accept pipeline input: True (ByPropertyName)
126138
Accept wildcard characters: False
127139
```
128140
@@ -160,13 +172,25 @@ value is case-senstive. File names of files stored in Azure File storage are not
160172
161173
```yaml
162174
Type: System.String[]
163-
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet, ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
175+
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet
164176
Aliases:
165177

166178
Required: True
167179
Position: Named
168180
Default value: None
169-
Accept pipeline input: False
181+
Accept pipeline input: True (ByPropertyName)
182+
Accept wildcard characters: False
183+
```
184+
185+
```yaml
186+
Type: System.String[]
187+
Parameter Sets: ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
188+
Aliases:
189+
190+
Required: True
191+
Position: Named
192+
Default value: None
193+
Accept pipeline input: True (ByPropertyName)
170194
Accept wildcard characters: False
171195
```
172196
@@ -175,13 +199,25 @@ Specifies the URI of the script file.
175199
176200
```yaml
177201
Type: System.String[]
178-
Parameter Sets: ByNameWithFileUriParameterSet, ByParentObjectWithFileUriParameterSet, ByResourceIdWithFileUriParameterSet, ByInputObjectWithFileUriParameterSet
202+
Parameter Sets: ByNameWithFileUriParameterSet
179203
Aliases:
180204

181205
Required: False
182206
Position: Named
183207
Default value: None
184-
Accept pipeline input: False
208+
Accept pipeline input: True (ByPropertyName)
209+
Accept wildcard characters: False
210+
```
211+
212+
```yaml
213+
Type: System.String[]
214+
Parameter Sets: ByParentObjectWithFileUriParameterSet, ByResourceIdWithFileUriParameterSet, ByInputObjectWithFileUriParameterSet
215+
Aliases:
216+
217+
Required: False
218+
Position: Named
219+
Default value: None
220+
Accept pipeline input: True (ByPropertyName)
185221
Accept wildcard characters: False
186222
```
187223
@@ -237,13 +273,25 @@ Specifies the name of the custom script extension.
237273
238274
```yaml
239275
Type: System.String
240-
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet, ByNameWithFileUriParameterSet, ByParentObjectWithContainerAndFileNamesParameterSet, ByParentObjectWithFileUriParameterSet
276+
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet, ByNameWithFileUriParameterSet
277+
Aliases: ExtensionName
278+
279+
Required: False
280+
Position: 1
281+
Default value: None
282+
Accept pipeline input: True (ByPropertyName)
283+
Accept wildcard characters: False
284+
```
285+
286+
```yaml
287+
Type: System.String
288+
Parameter Sets: ByParentObjectWithContainerAndFileNamesParameterSet, ByParentObjectWithFileUriParameterSet
241289
Aliases: ExtensionName
242290

243291
Required: True
244292
Position: 1
245293
Default value: None
246-
Accept pipeline input: False
294+
Accept pipeline input: True (ByPropertyName)
247295
Accept wildcard characters: False
248296
```
249297
@@ -258,7 +306,7 @@ Aliases:
258306
Required: True
259307
Position: 0
260308
Default value: None
261-
Accept pipeline input: False
309+
Accept pipeline input: True (ByPropertyName)
262310
Accept wildcard characters: False
263311
```
264312
@@ -288,7 +336,7 @@ Aliases: RunFile, Command
288336
Required: False
289337
Position: Named
290338
Default value: None
291-
Accept pipeline input: False
339+
Accept pipeline input: True (ByPropertyName)
292340
Accept wildcard characters: False
293341
```
294342
@@ -304,7 +352,7 @@ Aliases:
304352
Required: False
305353
Position: Named
306354
Default value: None
307-
Accept pipeline input: False
355+
Accept pipeline input: True (ByPropertyName)
308356
Accept wildcard characters: False
309357
```
310358
@@ -313,13 +361,25 @@ Specifies the key for the Azure storage container.
313361
314362
```yaml
315363
Type: System.String
316-
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet, ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
364+
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet
317365
Aliases:
318366

319367
Required: False
320368
Position: Named
321369
Default value: None
322-
Accept pipeline input: False
370+
Accept pipeline input: True (ByPropertyName)
371+
Accept wildcard characters: False
372+
```
373+
374+
```yaml
375+
Type: System.String
376+
Parameter Sets: ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
377+
Aliases:
378+
379+
Required: False
380+
Position: Named
381+
Default value: None
382+
Accept pipeline input: True (ByPropertyName)
323383
Accept wildcard characters: False
324384
```
325385
@@ -328,13 +388,25 @@ Specifies the name of the Azure storage account where this cmdlet stores the scr
328388
329389
```yaml
330390
Type: System.String
331-
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet, ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
391+
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet
332392
Aliases:
333393

334394
Required: False
335395
Position: Named
336396
Default value: None
337-
Accept pipeline input: False
397+
Accept pipeline input: True (ByPropertyName)
398+
Accept wildcard characters: False
399+
```
400+
401+
```yaml
402+
Type: System.String
403+
Parameter Sets: ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
404+
Aliases:
405+
406+
Required: False
407+
Position: Named
408+
Default value: None
409+
Accept pipeline input: True (ByPropertyName)
338410
Accept wildcard characters: False
339411
```
340412
@@ -343,13 +415,25 @@ Specifies the storage endpoint suffix.
343415
344416
```yaml
345417
Type: System.String
346-
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet, ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
418+
Parameter Sets: ByNameWithContainerAndFileNamesParameterSet
347419
Aliases:
348420

349421
Required: False
350422
Position: Named
351423
Default value: None
352-
Accept pipeline input: False
424+
Accept pipeline input: True (ByPropertyName)
425+
Accept wildcard characters: False
426+
```
427+
428+
```yaml
429+
Type: System.String
430+
Parameter Sets: ByParentObjectWithContainerAndFileNamesParameterSet, ByResourceIdWithContainerAndFileNamesParameterSet, ByInputObjectWithContainerAndFileNamesParameterSet
431+
Aliases:
432+
433+
Required: False
434+
Position: Named
435+
Default value: None
436+
Accept pipeline input: True (ByPropertyName)
353437
Accept wildcard characters: False
354438
```
355439
@@ -381,7 +465,7 @@ Aliases: ResourceName
381465
Required: True
382466
Position: Named
383467
Default value: None
384-
Accept pipeline input: False
468+
Accept pipeline input: True (ByPropertyName)
385469
Accept wildcard characters: False
386470
```
387471

0 commit comments

Comments
 (0)