Skip to content

Commit 4c8fc98

Browse files
grizzlytheodoreTheodore Chang
andauthored
add Get-AzVmRunCommand on SDK built cmdlet (#19272)
* add RunCommand * update * update * updates * fix capitalization CI failurue * update capitalization to match existing * Update BreakingChangeIssues.csv * Update BreakingChangeIssues.csv * Update BreakingChangeIssues.csv Co-authored-by: Theodore Chang <[email protected]>
1 parent 0fdda5c commit 4c8fc98

File tree

7 files changed

+164
-123
lines changed

7 files changed

+164
-123
lines changed

src/Compute/Compute/Az.Compute.psd1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ NestedModules = @('Microsoft.Azure.PowerShell.Cmdlets.Compute.dll',
7878
'Compute.Autorest\Az.Compute.psm1')
7979

8080
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
81-
FunctionsToExport = 'Get-AzGalleryApplication', 'Get-AzGalleryApplicationVersion',
82-
'Get-AzVMRunCommand', 'Get-AzVmssVMRunCommand',
81+
FunctionsToExport = 'Get-AzGalleryApplication', 'Get-AzGalleryApplicationVersion', 'Get-AzVmssVMRunCommand',
8382
'New-AzGalleryApplication', 'New-AzGalleryApplicationVersion',
8483
'Remove-AzGalleryApplication', 'Remove-AzGalleryApplicationVersion',
8584
'Remove-AzVMRunCommand', 'Remove-AzVmssVMRunCommand',
@@ -193,7 +192,7 @@ CmdletsToExport = 'Remove-AzAvailabilitySet', 'Get-AzAvailabilitySet',
193192
'New-AzVmGalleryApplication', 'New-AzVmssGalleryApplication',
194193
'Add-AzVmGalleryApplication', 'Add-AzVmssGalleryApplication',
195194
'Remove-AzVmGalleryApplication', 'Remove-AzVmssGalleryApplication',
196-
'Add-AzVmssRunCommand', 'Remove-AzVmssRunCommand'
195+
'Add-AzVmssRunCommand', 'Remove-AzVmssRunCommand', 'Get-AzVMRunCommand'
197196

198197
# Variables to export from this module
199198
VariablesToExport = '*'

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
-->
2222
## Upcoming Release
23+
* `Get-AzVMRunCommand` now shows all the properties of VMRunCommand in a list format.
2324
* Added new Parameter `-PublicIpSku` to the `NewAzVM` cmdlet with acceptable values : "Basic" and "Standard".
2425
* Added Generic Breaking Change PublicIpSku Warning and Overridden `-Zone` logic when `-PublicIpSku` is explicitly provided.
2526
* Added Disk Delete Optional parameters `OsDisk Deletion Option` and `Delete Option` to the `Set-AzVmssStorageProfile` (OS Disk) and `Add-AzVmssDataDisk` (Data Disk)

src/Compute/Compute/Manual/PSVirtualMachineRunCommand.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
namespace Microsoft.Azure.Management.Compute.Models
77
{
88

9-
public class PSVirtualMachineRunCommand : Resource
10-
{
9+
public class PSVirtualMachineRunCommand
10+
{
11+
public string Name { get; set; }
12+
public string Location { get; set; }
13+
public string Id { get; set; }
14+
public string Type { get; set; }
15+
public IDictionary<string, string> Tags { get; set; }
1116
public VirtualMachineRunCommandScriptSource Source { get; set; }
1217
public IList<RunCommandInputParameter> Parameters { get; set; }
1318
public IList<RunCommandInputParameter> ProtectedParameters { get; set; }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Microsoft.Azure.Management.Compute.Models;
5+
6+
namespace Microsoft.Azure.Commands.Compute.Automation.Models
7+
{
8+
public class PSVirtualMachineRunCommandList : PSVirtualMachineRunCommand
9+
{
10+
public PSVirtualMachineRunCommand ToPSVirtualMachineRunCommand()
11+
{
12+
return ComputeAutomationAutoMapperProfile.Mapper.Map<PSVirtualMachineRunCommand>(this);
13+
}
14+
}
15+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
using System.Linq;
19+
using System.Management.Automation;
20+
using Microsoft.Azure.Commands.Compute.Automation.Models;
21+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
22+
using Microsoft.Azure.Management.Compute;
23+
using Microsoft.Azure.Management.Compute.Models;
24+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
25+
26+
27+
namespace Microsoft.Azure.Commands.Compute.Automation
28+
{
29+
[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VMRunCommand")]
30+
[OutputType(typeof(PSVirtualMachineRunCommand))]
31+
public class GetAzureVmRunCommand : ComputeAutomationBaseCmdlet
32+
{
33+
[Parameter(
34+
ValueFromPipelineByPropertyName = true,
35+
Mandatory = true,
36+
HelpMessage = "Name of the resource group for the run command.")]
37+
[ResourceGroupCompleter]
38+
[SupportsWildcards]
39+
public string ResourceGroupName { get; set; }
40+
41+
[Parameter(
42+
ValueFromPipelineByPropertyName = true,
43+
Mandatory = true,
44+
HelpMessage = "Name of the virtual machine of the run command.")]
45+
[ResourceNameCompleter("Microsoft.Compute/virtualMachines", "ResourceGroupName")]
46+
public string VMName { get; set; }
47+
48+
[Parameter(
49+
Mandatory = false,
50+
ValueFromPipelineByPropertyName = true,
51+
HelpMessage = "Name of the run command.")]
52+
public string RunCommandName { get; set; }
53+
54+
[Parameter(
55+
Mandatory = false,
56+
ValueFromPipelineByPropertyName = true,
57+
HelpMessage = "For instance view, pass in \"InstanceView\".")]
58+
[PSArgumentCompleter("InstanceView")]
59+
public string Expand { get; set; }
60+
61+
public override void ExecuteCmdlet()
62+
{
63+
base.ExecuteCmdlet();
64+
ExecuteClientAction(() =>
65+
{
66+
67+
if (this.IsParameterBound(c => c.RunCommandName))
68+
{
69+
VirtualMachineRunCommand vmRc = VirtualMachineRunCommandsClient.GetByVirtualMachine(this.ResourceGroupName, this.VMName, this.RunCommandName, this.Expand);
70+
PSVirtualMachineRunCommand psObject = new PSVirtualMachineRunCommand();
71+
ComputeAutomationAutoMapperProfile.Mapper.Map<VirtualMachineRunCommand, PSVirtualMachineRunCommand>(vmRc, psObject);
72+
WriteObject(psObject);
73+
}
74+
else
75+
{
76+
var vmRc = VirtualMachineRunCommandsClient.ListByVirtualMachine(this.ResourceGroupName, this.VMName, this.Expand);
77+
var resultList = vmRc.ToList();
78+
var nextPageLink = vmRc.NextPageLink;
79+
while (!string.IsNullOrEmpty(nextPageLink))
80+
{
81+
var pageResult = VirtualMachineRunCommandsClient.ListByVirtualMachineNext(nextPageLink);
82+
foreach (var pageItem in pageResult)
83+
{
84+
resultList.Add(pageItem);
85+
}
86+
nextPageLink = pageResult.NextPageLink;
87+
}
88+
var psObject = new List<PSVirtualMachineRunCommand>();
89+
foreach (var r in resultList)
90+
{
91+
psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map<VirtualMachineRunCommand, PSVirtualMachineRunCommandList>(r));
92+
}
93+
WriteObject(psObject);
94+
}
95+
});
96+
}
97+
}
98+
}

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

Lines changed: 18 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,20 @@
11
---
2-
external help file: Az.Compute-help.xml
2+
external help file: Microsoft.Azure.PowerShell.Cmdlets.Compute.dll-Help.xml
33
Module Name: Az.Compute
4-
online version: https://docs.microsoft.com/powershell/module/az.compute/get-azvmruncommand
4+
online version: https://docs.microsoft.com/powershell/module/az.compute/Get-AzVMRunCommand
55
schema: 2.0.0
66
---
77

88
# Get-AzVMRunCommand
99

1010
## SYNOPSIS
11-
Gets specific run command for a subscription in a location.
11+
Gets a specific Run Command or a list of Run Commands for a Virtual Machine
1212

1313
## SYNTAX
1414

15-
### List (Default)
16-
```
17-
Get-AzVMRunCommand -Location <String> [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
18-
[<CommonParameters>]
19-
```
20-
21-
### Get
22-
```
23-
Get-AzVMRunCommand -CommandId <String> -Location <String> [-SubscriptionId <String[]>]
24-
[-DefaultProfile <PSObject>] [<CommonParameters>]
25-
```
26-
27-
### List1
28-
```
29-
Get-AzVMRunCommand [-SubscriptionId <String[]>] -ResourceGroupName <String> -VMName <String> [-Expand <String>]
30-
[-DefaultProfile <PSObject>] [<CommonParameters>]
31-
```
32-
33-
### Get1
3415
```
35-
Get-AzVMRunCommand [-SubscriptionId <String[]>] -ResourceGroupName <String> -RunCommandName <String>
36-
-VMName <String> [-Expand <String>] [-DefaultProfile <PSObject>] [<CommonParameters>]
37-
```
38-
39-
### GetViaIdentity
40-
```
41-
Get-AzVMRunCommand -InputObject <IComputeIdentity> [-DefaultProfile <PSObject>] [<CommonParameters>]
16+
Get-AzVMRunCommand -ResourceGroupName <String> -VMName <String> [-RunCommandName <String>] [-Expand <String>]
17+
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
4218
```
4319

4420
## DESCRIPTION
@@ -51,11 +27,6 @@ Gets specific run command for a subscription in a location.
5127
Get-AzVMRunCommand -ResourceGroupName $rgname -VMName $vmname -RunCommandName "firstruncommand2"
5228
```
5329

54-
```output
55-
Location Name Type
56-
-------- ---- ----
57-
eastus firstruncommand2 Microsoft.Compute/virtualMachines/runCommands
58-
```
5930

6031
Get Run Command by it's name.
6132

@@ -64,40 +35,17 @@ Get Run Command by it's name.
6435
Get-AzVMRunCommand -ResourceGroupName $rgname -VMName $vmname
6536
```
6637

67-
```output
68-
Location Name Type
69-
-------- ---- ----
70-
eastus firstruncommand Microsoft.Compute/virtualMachines/runCommands
71-
eastus firstruncommand2 Microsoft.Compute/virtualMachines/runCommands
72-
eastus firstruncommand3 Microsoft.Compute/virtualMachines/runCommands
73-
```
74-
7538
Get Run Commands by VM name
7639

7740
## PARAMETERS
7841

79-
### -CommandId
80-
The command id.
81-
82-
```yaml
83-
Type: System.String
84-
Parameter Sets: Get
85-
Aliases:
86-
87-
Required: True
88-
Position: Named
89-
Default value: None
90-
Accept pipeline input: False
91-
Accept wildcard characters: False
92-
```
93-
9442
### -DefaultProfile
9543
The credentials, account, tenant, and subscription used for communication with Azure.
9644

9745
```yaml
98-
Type: System.Management.Automation.PSObject
46+
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
9947
Parameter Sets: (All)
100-
Aliases: AzureRMContext, AzureCredential
48+
Aliases: AzContext, AzureRmContext, AzureCredential
10149

10250
Required: False
10351
Position: Named
@@ -107,48 +55,17 @@ Accept wildcard characters: False
10755
```
10856
10957
### -Expand
110-
The expand expression to apply on the operation.
58+
The expand expression to apply on the operation. Possible value(s): InstanceView
11159
11260
```yaml
11361
Type: System.String
114-
Parameter Sets: List1, Get1
62+
Parameter Sets: (All)
11563
Aliases:
11664

11765
Required: False
11866
Position: Named
11967
Default value: None
120-
Accept pipeline input: False
121-
Accept wildcard characters: False
122-
```
123-
124-
### -InputObject
125-
Identity Parameter
126-
To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
127-
128-
```yaml
129-
Type: Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.IComputeIdentity
130-
Parameter Sets: GetViaIdentity
131-
Aliases:
132-
133-
Required: True
134-
Position: Named
135-
Default value: None
136-
Accept pipeline input: True (ByValue)
137-
Accept wildcard characters: False
138-
```
139-
140-
### -Location
141-
The location upon which run commands is queried.
142-
143-
```yaml
144-
Type: System.String
145-
Parameter Sets: List, Get
146-
Aliases:
147-
148-
Required: True
149-
Position: Named
150-
Default value: None
151-
Accept pipeline input: False
68+
Accept pipeline input: True (ByPropertyName)
15269
Accept wildcard characters: False
15370
```
15471
@@ -157,44 +74,28 @@ The name of the resource group.
15774
15875
```yaml
15976
Type: System.String
160-
Parameter Sets: List1, Get1
77+
Parameter Sets: (All)
16178
Aliases:
16279

16380
Required: True
16481
Position: Named
16582
Default value: None
166-
Accept pipeline input: False
167-
Accept wildcard characters: False
83+
Accept pipeline input: True (ByPropertyName)
84+
Accept wildcard characters: True
16885
```
16986
17087
### -RunCommandName
17188
The name of the virtual machine run command.
17289
17390
```yaml
17491
Type: System.String
175-
Parameter Sets: Get1
176-
Aliases:
177-
178-
Required: True
179-
Position: Named
180-
Default value: None
181-
Accept pipeline input: False
182-
Accept wildcard characters: False
183-
```
184-
185-
### -SubscriptionId
186-
Subscription credentials which uniquely identify Microsoft Azure subscription.
187-
The subscription ID forms part of the URI for every service call.
188-
189-
```yaml
190-
Type: System.String[]
191-
Parameter Sets: List, Get, List1, Get1
92+
Parameter Sets: (All)
19293
Aliases:
19394

19495
Required: False
19596
Position: Named
196-
Default value: (Get-AzContext).Subscription.Id
197-
Accept pipeline input: False
97+
Default value: None
98+
Accept pipeline input: True (ByPropertyName)
19899
Accept wildcard characters: False
199100
```
200101
@@ -203,13 +104,13 @@ The name of the virtual machine containing the run command.
203104
204105
```yaml
205106
Type: System.String
206-
Parameter Sets: List1, Get1
107+
Parameter Sets: (All)
207108
Aliases:
208109

209110
Required: True
210111
Position: Named
211112
Default value: None
212-
Accept pipeline input: False
113+
Accept pipeline input: True (ByPropertyName)
213114
Accept wildcard characters: False
214115
```
215116

0 commit comments

Comments
 (0)