Skip to content

Commit c9a0d1b

Browse files
Add cmdlet help examples for RunCommand v2 (Set, Get) cmdlets (#19969)
* Add cmdlet help examples for RunCommand v2 (Set, Get) cmdlets * Minor cmdlet help description changes * Revert changes related to Set-AzVMRunCommand and Set-AzVmssVMRunCommand examples and help docs as they've been copied in a different PR already * address comment
1 parent 68fee2a commit c9a0d1b

File tree

6 files changed

+234
-20
lines changed

6 files changed

+234
-20
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
### Example 1: Get a Run Command for VM
2+
3+
```powershell
4+
Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM -RunCommandName MyRunCommand
5+
```
6+
7+
Get a Run Command for VM without Instance View.
8+
9+
### Example 2: Get a Run Command for VM with Instance View
10+
11+
```powershell
12+
$x = Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM -RunCommandName MyRunCommand -Expand InstanceView
13+
$x.InstanceView
14+
```
15+
16+
```output
17+
ExecutionState : Succeeded
18+
ExecutionMessage :
19+
ExitCode : 0
20+
Output : Directory: C:\
21+
22+
23+
Mode LastWriteTime Length Name
24+
---- ------------- ------ ----
25+
-a---- 10/27/2022 9:10 PM 0 HelloWorld2022-10-27T21.10.54.9266231+00.00.txt
26+
27+
28+
Error :
29+
StartTime : 10/27/2022 9:10:52 PM
30+
EndTime : 10/27/2022 9:10:55 PM
31+
Statuses :
32+
```
33+
34+
Get a Run Command for VM with Instance View. Instance View contains execution state of run command (Succeeded, Failed, etc.), exit code, standard output and standard error generated by executing the script using Run Command. A non-zero ExitCode indicates an unsuccessful execution.
35+
36+
### Example 3: Get all Run Commands for a VM
37+
38+
```powershell
39+
Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM
40+
```
41+
42+
Get list of all Run Commands for a VM.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
### Example 1: Get a Run Command for VMSS VM instance
2+
3+
```powershell
4+
Get-AzVmssVMRunCommand -ResourceGroupName MyRG0 -VMScaleSetName MyVMSS -InstanceId 0 -RunCommandName MyRunCommand
5+
```
6+
7+
Get a Run Command for VM without Instance View.
8+
9+
### Example 2: Get a Run Command for VMSS VM instance with Instance View
10+
11+
```powershell
12+
$x = Get-AzVmssVMRunCommand -ResourceGroupName MyRG0 -VMScaleSetName MyVMSS -InstanceId 0 -RunCommandName MyRunCommand -Expand InstanceView
13+
$x.InstanceView
14+
```
15+
16+
```output
17+
ExecutionState : Succeeded
18+
ExecutionMessage :
19+
ExitCode : 0
20+
Output : Directory: C:\
21+
22+
23+
Mode LastWriteTime Length Name
24+
---- ------------- ------ ----
25+
-a---- 10/27/2022 9:10 PM 0 HelloWorld2022-10-27T21.10.54.9266231+00.00.txt
26+
27+
28+
Error :
29+
StartTime : 10/27/2022 9:10:52 PM
30+
EndTime : 10/27/2022 9:10:55 PM
31+
Statuses :
32+
```
33+
34+
Get a Run Command for VM with Instance View. Instance View contains execution state of run command (Succeeded, Failed, etc.), exit code, standard output and standard error generated by executing the script using Run Command. A non-zero ExitCode indicates an unsuccessful execution.
35+
36+
### Example 3: Get all Run Commands for a VMSS VM instance
37+
38+
```powershell
39+
Get-AzVmssVMRunCommand -ResourceGroupName MyRG -VMScaleSetName MyVMSS -InstanceId 1
40+
```
41+
42+
Get list of all Run Commands for a VM.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
### Example 1: Get a Run Command for VM
2+
3+
```powershell
4+
Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM -RunCommandName MyRunCommand
5+
```
6+
7+
Get a Run Command for VM without Instance View.
8+
9+
### Example 2: Get a Run Command for VM with Instance View
10+
11+
```powershell
12+
$x = Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM -RunCommandName MyRunCommand -Expand InstanceView
13+
$x.InstanceView
14+
```
15+
16+
```output
17+
ExecutionState : Succeeded
18+
ExecutionMessage :
19+
ExitCode : 0
20+
Output : Directory: C:\
21+
22+
23+
Mode LastWriteTime Length Name
24+
---- ------------- ------ ----
25+
-a---- 10/27/2022 9:10 PM 0 HelloWorld2022-10-27T21.10.54.9266231+00.00.txt
26+
27+
28+
Error :
29+
StartTime : 10/27/2022 9:10:52 PM
30+
EndTime : 10/27/2022 9:10:55 PM
31+
Statuses :
32+
```
33+
34+
Get a Run Command for VM with Instance View. Instance View contains execution state of run command (Succeeded, Failed, etc.), exit code, standard output and standard error generated by executing the script using Run Command. A non-zero ExitCode indicates an unsuccessful execution.
35+
36+
### Example 3: Get all Run Commands for a VM
37+
38+
```powershell
39+
Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM
40+
```
41+
42+
Get list of all Run Commands for a VM.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
### Example 1: Get a Run Command for VMSS VM instance
2+
3+
```powershell
4+
Get-AzVmssVMRunCommand -ResourceGroupName MyRG0 -VMScaleSetName MyVMSS -InstanceId 0 -RunCommandName MyRunCommand
5+
```
6+
7+
Get a Run Command for VMSS VM without Instance View.
8+
9+
### Example 2: Get a Run Command for VMSS VM instance with Instance View
10+
11+
```powershell
12+
$x = Get-AzVmssVMRunCommand -ResourceGroupName MyRG0 -VMScaleSetName MyVMSS -InstanceId 0 -RunCommandName MyRunCommand -Expand InstanceView
13+
$x.InstanceView
14+
```
15+
16+
```output
17+
ExecutionState : Succeeded
18+
ExecutionMessage :
19+
ExitCode : 0
20+
Output : Directory: C:\
21+
22+
23+
Mode LastWriteTime Length Name
24+
---- ------------- ------ ----
25+
-a---- 10/27/2022 9:10 PM 0 HelloWorld2022-10-27T21.10.54.9266231+00.00.txt
26+
27+
28+
Error :
29+
StartTime : 10/27/2022 9:10:52 PM
30+
EndTime : 10/27/2022 9:10:55 PM
31+
Statuses :
32+
```
33+
34+
Get a Run Command for VMSS VM with Instance View. Instance View contains execution state of run command (Succeeded, Failed, etc.), exit code, standard output and standard error generated by executing the script using Run Command. A non-zero ExitCode indicates an unsuccessful execution.
35+
36+
### Example 3: Get all Run Commands for a VMSS VM instance
37+
38+
```powershell
39+
Get-AzVmssVMRunCommand -ResourceGroupName MyRG -VMScaleSetName MyVMSS -InstanceId 1
40+
```
41+
42+
Get list of all Run Commands for a VM.

src/Compute/Compute/help/Get-AzVMRunCommand.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,48 @@ Gets specific run command for a subscription in a location.
2222

2323
## EXAMPLES
2424

25-
### Example 1: Get Run Command by Name
25+
### Example 1: Get a Run Command for VM.
26+
2627
```powershell
27-
Get-AzVMRunCommand -ResourceGroupName $rgname -VMName $vmname -RunCommandName "firstruncommand2"
28+
Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM -RunCommandName MyRunCommand
2829
```
2930

30-
Get Run Command by it's name.
31+
Get a Run Command for VM without Instance View.
32+
33+
### Example 2: Get a Run Command for VM with Instance View
34+
35+
```powershell
36+
$x = Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM -RunCommandName MyRunCommand -Expand InstanceView
37+
$x.InstanceView
38+
```
39+
40+
```output
41+
ExecutionState : Succeeded
42+
ExecutionMessage :
43+
ExitCode : 0
44+
Output : Directory: C:\
45+
46+
47+
Mode LastWriteTime Length Name
48+
---- ------------- ------ ----
49+
-a---- 10/27/2022 9:10 PM 0 HelloWorld2022-10-27T21.10.54.9266231+00.00.txt
50+
51+
52+
Error :
53+
StartTime : 10/27/2022 9:10:52 PM
54+
EndTime : 10/27/2022 9:10:55 PM
55+
Statuses :
56+
```
57+
58+
Get a Run Command for VM with Instance View. Instance View contains execution state of run command (Succeeded, Failed, etc.), exit code, standard output and standard error generated by executing the script using Run Command. A non-zero ExitCode indicates an unsuccessful execution.
59+
60+
### Example 3: Get all Run Commands for a VM
3161

32-
### Example 2: Get Run Commands by VM
3362
```powershell
34-
Get-AzVMRunCommand -ResourceGroupName $rgname -VMName $vmname
63+
Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM
3564
```
3665

37-
Get Run Commands by VM name
66+
Get all Run Commands for a VM
3867

3968
## PARAMETERS
4069

src/Compute/Compute/help/Get-AzVmssVMRunCommand.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,48 @@ The operation to get the VMSS VM run command.
2222

2323
## EXAMPLES
2424

25-
### Example 1: Get RunCommand by name
25+
### Example 1: Get a Run Command for VMSS VM instance
26+
2627
```powershell
27-
Get-AzVmssVMRunCommand -InstanceId 3 -ResourceGroupName $rgname -RunCommandName "first" -VMScaleSetName $vmssname
28+
Get-AzVmssVMRunCommand -ResourceGroupName MyRG0 -VMScaleSetName MyVMSS -InstanceId 0 -RunCommandName MyRunCommand
2829
```
2930

30-
```output
31-
Location Name Type
32-
-------- ---- ----
33-
eastus first Microsoft.Compute/virtualMachineScaleSets/virtualMachines/runCommands
34-
```
31+
Get a Run Command for VM without Instance View.
3532

36-
Get by runcommand name
33+
### Example 2: Get a Run Command for VMSS VM instance with Instance View
3734

38-
### Example 2: Get RunCommand by Instance
3935
```powershell
40-
Get-AzVmssVMRunCommand -InstanceId 3 -ResourceGroupName $rgname -VMScaleSetName $vmssname
36+
$x = Get-AzVmssVMRunCommand -ResourceGroupName MyRG0 -VMScaleSetName MyVMSS -InstanceId 0 -RunCommandName MyRunCommand -Expand InstanceView
37+
$x.InstanceView
4138
```
4239

4340
```output
44-
Location Name Type
45-
-------- ---- ----
46-
eastus first Microsoft.Compute/virtualMachineScaleSets/virtualMachines/runCommands
41+
ExecutionState : Succeeded
42+
ExecutionMessage :
43+
ExitCode : 0
44+
Output : Directory: C:\
45+
46+
47+
Mode LastWriteTime Length Name
48+
---- ------------- ------ ----
49+
-a---- 10/27/2022 9:10 PM 0 HelloWorld2022-10-27T21.10.54.9266231+00.00.txt
50+
51+
52+
Error :
53+
StartTime : 10/27/2022 9:10:52 PM
54+
EndTime : 10/27/2022 9:10:55 PM
55+
Statuses :
56+
```
57+
58+
Get a Run Command for VM with Instance View. Instance View contains execution state of run command (Succeeded, Failed, etc.), exit code, standard output and standard error generated by executing the script using Run Command. A non-zero ExitCode indicates an unsuccessful execution.
59+
60+
### Example 3: Get all Run Commands for a VMSS VM instance
61+
62+
```powershell
63+
Get-AzVmssVMRunCommand -ResourceGroupName MyRG -VMScaleSetName MyVMSS -InstanceId 1
4764
```
4865

49-
Get RunCommand by Instance
66+
Get list of all Run Commands for a VM.
5067

5168
## PARAMETERS
5269

0 commit comments

Comments
 (0)