diff --git a/src/Compute/Compute/Az.Compute.psd1 b/src/Compute/Compute/Az.Compute.psd1 index 57f0bb462752..0c57e9f72fca 100644 --- a/src/Compute/Compute/Az.Compute.psd1 +++ b/src/Compute/Compute/Az.Compute.psd1 @@ -78,8 +78,7 @@ NestedModules = @('Microsoft.Azure.PowerShell.Cmdlets.Compute.dll', 'Compute.Autorest\Az.Compute.psm1') # 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. -FunctionsToExport = 'Get-AzGalleryApplication', 'Get-AzGalleryApplicationVersion', - 'Get-AzVMRunCommand', 'Get-AzVmssVMRunCommand', +FunctionsToExport = 'Get-AzGalleryApplication', 'Get-AzGalleryApplicationVersion', 'Get-AzVmssVMRunCommand', 'New-AzGalleryApplication', 'New-AzGalleryApplicationVersion', 'Remove-AzGalleryApplication', 'Remove-AzGalleryApplicationVersion', 'Remove-AzVMRunCommand', 'Remove-AzVmssVMRunCommand', @@ -193,7 +192,7 @@ CmdletsToExport = 'Remove-AzAvailabilitySet', 'Get-AzAvailabilitySet', 'New-AzVmGalleryApplication', 'New-AzVmssGalleryApplication', 'Add-AzVmGalleryApplication', 'Add-AzVmssGalleryApplication', 'Remove-AzVmGalleryApplication', 'Remove-AzVmssGalleryApplication', - 'Add-AzVmssRunCommand', 'Remove-AzVmssRunCommand' + 'Add-AzVmssRunCommand', 'Remove-AzVmssRunCommand', 'Get-AzVMRunCommand' # Variables to export from this module VariablesToExport = '*' diff --git a/src/Compute/Compute/ChangeLog.md b/src/Compute/Compute/ChangeLog.md index cbca14f7ce1f..20b53f31fbd3 100644 --- a/src/Compute/Compute/ChangeLog.md +++ b/src/Compute/Compute/ChangeLog.md @@ -20,6 +20,7 @@ --> ## Upcoming Release +* `Get-AzVMRunCommand` now shows all the properties of VMRunCommand in a list format. * Added new Parameter `-PublicIpSku` to the `NewAzVM` cmdlet with acceptable values : "Basic" and "Standard". * Added Generic Breaking Change PublicIpSku Warning and Overridden `-Zone` logic when `-PublicIpSku` is explicitly provided. * Added Disk Delete Optional parameters `OsDisk Deletion Option` and `Delete Option` to the `Set-AzVmssStorageProfile` (OS Disk) and `Add-AzVmssDataDisk` (Data Disk) diff --git a/src/Compute/Compute/Manual/PSVirtualMachineRunCommand.cs b/src/Compute/Compute/Manual/PSVirtualMachineRunCommand.cs index 598c7468c4b1..e65349fb1a68 100644 --- a/src/Compute/Compute/Manual/PSVirtualMachineRunCommand.cs +++ b/src/Compute/Compute/Manual/PSVirtualMachineRunCommand.cs @@ -6,8 +6,13 @@ namespace Microsoft.Azure.Management.Compute.Models { - public class PSVirtualMachineRunCommand : Resource - { + public class PSVirtualMachineRunCommand + { + public string Name { get; set; } + public string Location { get; set; } + public string Id { get; set; } + public string Type { get; set; } + public IDictionary Tags { get; set; } public VirtualMachineRunCommandScriptSource Source { get; set; } public IList Parameters { get; set; } public IList ProtectedParameters { get; set; } diff --git a/src/Compute/Compute/Models/PSVirtualMachineRunCommandList.cs b/src/Compute/Compute/Models/PSVirtualMachineRunCommandList.cs new file mode 100644 index 000000000000..3babfd315195 --- /dev/null +++ b/src/Compute/Compute/Models/PSVirtualMachineRunCommandList.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.Azure.Management.Compute.Models; + +namespace Microsoft.Azure.Commands.Compute.Automation.Models +{ + public class PSVirtualMachineRunCommandList : PSVirtualMachineRunCommand + { + public PSVirtualMachineRunCommand ToPSVirtualMachineRunCommand() + { + return ComputeAutomationAutoMapperProfile.Mapper.Map(this); + } + } +} diff --git a/src/Compute/Compute/VirtualMachine/RunCommand/GetAzVmRunCommand.cs b/src/Compute/Compute/VirtualMachine/RunCommand/GetAzVmRunCommand.cs new file mode 100644 index 000000000000..02d6894d59c5 --- /dev/null +++ b/src/Compute/Compute/VirtualMachine/RunCommand/GetAzVmRunCommand.cs @@ -0,0 +1,98 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; +using Microsoft.Azure.Commands.Compute.Automation.Models; +using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; +using Microsoft.Azure.Management.Compute; +using Microsoft.Azure.Management.Compute.Models; +using Microsoft.WindowsAzure.Commands.Utilities.Common; + + +namespace Microsoft.Azure.Commands.Compute.Automation +{ + [Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VMRunCommand")] + [OutputType(typeof(PSVirtualMachineRunCommand))] + public class GetAzureVmRunCommand : ComputeAutomationBaseCmdlet + { + [Parameter( + ValueFromPipelineByPropertyName = true, + Mandatory = true, + HelpMessage = "Name of the resource group for the run command.")] + [ResourceGroupCompleter] + [SupportsWildcards] + public string ResourceGroupName { get; set; } + + [Parameter( + ValueFromPipelineByPropertyName = true, + Mandatory = true, + HelpMessage = "Name of the virtual machine of the run command.")] + [ResourceNameCompleter("Microsoft.Compute/virtualMachines", "ResourceGroupName")] + public string VMName { get; set; } + + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Name of the run command.")] + public string RunCommandName { get; set; } + + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "For instance view, pass in \"InstanceView\".")] + [PSArgumentCompleter("InstanceView")] + public string Expand { get; set; } + + public override void ExecuteCmdlet() + { + base.ExecuteCmdlet(); + ExecuteClientAction(() => + { + + if (this.IsParameterBound(c => c.RunCommandName)) + { + VirtualMachineRunCommand vmRc = VirtualMachineRunCommandsClient.GetByVirtualMachine(this.ResourceGroupName, this.VMName, this.RunCommandName, this.Expand); + PSVirtualMachineRunCommand psObject = new PSVirtualMachineRunCommand(); + ComputeAutomationAutoMapperProfile.Mapper.Map(vmRc, psObject); + WriteObject(psObject); + } + else + { + var vmRc = VirtualMachineRunCommandsClient.ListByVirtualMachine(this.ResourceGroupName, this.VMName, this.Expand); + var resultList = vmRc.ToList(); + var nextPageLink = vmRc.NextPageLink; + while (!string.IsNullOrEmpty(nextPageLink)) + { + var pageResult = VirtualMachineRunCommandsClient.ListByVirtualMachineNext(nextPageLink); + foreach (var pageItem in pageResult) + { + resultList.Add(pageItem); + } + nextPageLink = pageResult.NextPageLink; + } + var psObject = new List(); + foreach (var r in resultList) + { + psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map(r)); + } + WriteObject(psObject); + } + }); + } + } +} diff --git a/src/Compute/Compute/help/Get-AzVMRunCommand.md b/src/Compute/Compute/help/Get-AzVMRunCommand.md index a14afd361bfb..f1b1c322fc6d 100644 --- a/src/Compute/Compute/help/Get-AzVMRunCommand.md +++ b/src/Compute/Compute/help/Get-AzVMRunCommand.md @@ -1,44 +1,20 @@ --- -external help file: Az.Compute-help.xml +external help file: Microsoft.Azure.PowerShell.Cmdlets.Compute.dll-Help.xml Module Name: Az.Compute -online version: https://docs.microsoft.com/powershell/module/az.compute/get-azvmruncommand +online version: https://docs.microsoft.com/powershell/module/az.compute/Get-AzVMRunCommand schema: 2.0.0 --- # Get-AzVMRunCommand ## SYNOPSIS -Gets specific run command for a subscription in a location. +Gets a specific Run Command or a list of Run Commands for a Virtual Machine ## SYNTAX -### List (Default) -``` -Get-AzVMRunCommand -Location [-SubscriptionId ] [-DefaultProfile ] - [] -``` - -### Get -``` -Get-AzVMRunCommand -CommandId -Location [-SubscriptionId ] - [-DefaultProfile ] [] -``` - -### List1 -``` -Get-AzVMRunCommand [-SubscriptionId ] -ResourceGroupName -VMName [-Expand ] - [-DefaultProfile ] [] -``` - -### Get1 ``` -Get-AzVMRunCommand [-SubscriptionId ] -ResourceGroupName -RunCommandName - -VMName [-Expand ] [-DefaultProfile ] [] -``` - -### GetViaIdentity -``` -Get-AzVMRunCommand -InputObject [-DefaultProfile ] [] +Get-AzVMRunCommand -ResourceGroupName -VMName [-RunCommandName ] [-Expand ] + [-DefaultProfile ] [] ``` ## DESCRIPTION @@ -51,11 +27,6 @@ Gets specific run command for a subscription in a location. Get-AzVMRunCommand -ResourceGroupName $rgname -VMName $vmname -RunCommandName "firstruncommand2" ``` -```output -Location Name Type --------- ---- ---- -eastus firstruncommand2 Microsoft.Compute/virtualMachines/runCommands -``` Get Run Command by it's name. @@ -64,40 +35,17 @@ Get Run Command by it's name. Get-AzVMRunCommand -ResourceGroupName $rgname -VMName $vmname ``` -```output -Location Name Type --------- ---- ---- -eastus firstruncommand Microsoft.Compute/virtualMachines/runCommands -eastus firstruncommand2 Microsoft.Compute/virtualMachines/runCommands -eastus firstruncommand3 Microsoft.Compute/virtualMachines/runCommands -``` - Get Run Commands by VM name ## PARAMETERS -### -CommandId -The command id. - -```yaml -Type: System.String -Parameter Sets: Get -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -DefaultProfile The credentials, account, tenant, and subscription used for communication with Azure. ```yaml -Type: System.Management.Automation.PSObject +Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer Parameter Sets: (All) -Aliases: AzureRMContext, AzureCredential +Aliases: AzContext, AzureRmContext, AzureCredential Required: False Position: Named @@ -107,48 +55,17 @@ Accept wildcard characters: False ``` ### -Expand -The expand expression to apply on the operation. +The expand expression to apply on the operation. Possible value(s): InstanceView ```yaml Type: System.String -Parameter Sets: List1, Get1 +Parameter Sets: (All) Aliases: Required: False Position: Named Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -Identity Parameter -To construct, see NOTES section for INPUTOBJECT properties and create a hash table. - -```yaml -Type: Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.IComputeIdentity -Parameter Sets: GetViaIdentity -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Location -The location upon which run commands is queried. - -```yaml -Type: System.String -Parameter Sets: List, Get -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` @@ -157,14 +74,14 @@ The name of the resource group. ```yaml Type: System.String -Parameter Sets: List1, Get1 +Parameter Sets: (All) Aliases: Required: True Position: Named Default value: None -Accept pipeline input: False -Accept wildcard characters: False +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: True ``` ### -RunCommandName @@ -172,29 +89,13 @@ The name of the virtual machine run command. ```yaml Type: System.String -Parameter Sets: Get1 -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SubscriptionId -Subscription credentials which uniquely identify Microsoft Azure subscription. -The subscription ID forms part of the URI for every service call. - -```yaml -Type: System.String[] -Parameter Sets: List, Get, List1, Get1 +Parameter Sets: (All) Aliases: Required: False Position: Named -Default value: (Get-AzContext).Subscription.Id -Accept pipeline input: False +Default value: None +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` @@ -203,13 +104,13 @@ The name of the virtual machine containing the run command. ```yaml Type: System.String -Parameter Sets: List1, Get1 +Parameter Sets: (All) Aliases: Required: True Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` diff --git a/tools/StaticAnalysis/Exceptions/Az.Compute/BreakingChangeIssues.csv b/tools/StaticAnalysis/Exceptions/Az.Compute/BreakingChangeIssues.csv index b414ae9f8062..2b670377166b 100644 --- a/tools/StaticAnalysis/Exceptions/Az.Compute/BreakingChangeIssues.csv +++ b/tools/StaticAnalysis/Exceptions/Az.Compute/BreakingChangeIssues.csv @@ -3,4 +3,26 @@ "Az.Compute","New-AzGalleryApplicationVersion","New-AzGalleryApplicationVersion","0","1020","The cmdlet 'New-AzGalleryApplicationVersion' no longer has output type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IGalleryApplicationVersion'.","Make cmdlet 'New-AzGalleryApplicationVersion' return type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IGalleryApplicationVersion'." "Az.Compute","Update-AzGalleryApplicationVersion","Update-AzGalleryApplicationVersion","0","1020","The cmdlet 'Update-AzGalleryApplicationVersion' no longer has output type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IGalleryApplicationVersion'.","Make cmdlet 'Update-AzGalleryApplicationVersion' return type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IGalleryApplicationVersion'." "Az.Compute","Get-AzGalleryApplicationVersion","Get-AzGalleryApplicationVersion","0","1020","The cmdlet 'Get-AzGalleryApplicationVersion' no longer has output type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IGalleryApplicationVersion'.","Make cmdlet 'Get-AzGalleryApplicationVersion' return type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IGalleryApplicationVersion'." -"Az.Compute","Microsoft.Azure.Commands.Compute.UpdateAzureVMCommand","Update-AzVM","0","2090","The ValidateNotNullOrEmpty attribute has been added to parameter 'IdentityId' for cmdlet 'Update-AzVM'.","Remove the ValidateNotNullOrEmpty attribute from parameter 'IdentityId'." \ No newline at end of file +"Az.Compute","Microsoft.Azure.Commands.Compute.UpdateAzureVMCommand","Update-AzVM","0","2090","The ValidateNotNullOrEmpty attribute has been added to parameter 'IdentityId' for cmdlet 'Update-AzVM'.","Remove the ValidateNotNullOrEmpty attribute from parameter 'IdentityId'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1060","The parameter set 'List' for cmdlet 'Get-AzVMRunCommand' is no longer the default parameter set.","Change the default parameter for cmdlet 'Get-AzVMRunCommand' back to 'List'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'CommandId' and no alias was found for the original parameter name.","Add the parameter 'CommandId' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'Location' and no alias was found for the original parameter name.","Add the parameter 'Location' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'SubscriptionId' and no alias was found for the original parameter name.","Add the parameter 'SubscriptionId' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'InputObject' and no alias was found for the original parameter name.","Add the parameter 'InputObject' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2020","The cmdlet 'Get-AzVMRunCommand' no longer supports the type 'System.Management.Automation.PSObject' for parameter 'DefaultProfile'.","Change the type for parameter 'DefaultProfile' back to 'System.Management.Automation.PSObject'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2010","The cmdlet 'Get-AzVMRunCommand' no longer supports the alias 'AzureRMContext' for parameter 'DefaultProfile'.","Add the alias 'AzureRMContext' back to parameter 'DefaultProfile'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'Break' and no alias was found for the original parameter name.","Add the parameter 'Break' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'HttpPipelineAppend' and no alias was found for the original parameter name.","Add the parameter 'HttpPipelineAppend' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'HttpPipelinePrepend' and no alias was found for the original parameter name.","Add the parameter 'HttpPipelinePrepend' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'Proxy' and no alias was found for the original parameter name.","Add the parameter 'Proxy' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'ProxyCredential' and no alias was found for the original parameter name.","Add the parameter 'ProxyCredential' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","2000","The cmdlet 'Get-AzVMRunCommand' no longer supports the parameter 'ProxyUseDefaultCredentials' and no alias was found for the original parameter name.","Add the parameter 'ProxyUseDefaultCredentials' back to the cmdlet 'Get-AzVMRunCommand', or add an alias to the original parameter name." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1050","The parameter set 'Get' for cmdlet 'Get-AzVMRunCommand' has been removed.","Add parameter set 'Get' back to cmdlet 'Get-AzVMRunCommand'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1050","The parameter set 'List' for cmdlet 'Get-AzVMRunCommand' has been removed.","Add parameter set 'List' back to cmdlet 'Get-AzVMRunCommand'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1050","The parameter set 'List1' for cmdlet 'Get-AzVMRunCommand' has been removed.","Add parameter set 'List1' back to cmdlet 'Get-AzVMRunCommand'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1050","The parameter set 'Get1' for cmdlet 'Get-AzVMRunCommand' has been removed.","Add parameter set 'Get1' back to cmdlet 'Get-AzVMRunCommand'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1050","The parameter set 'GetViaIdentity' for cmdlet 'Get-AzVMRunCommand' has been removed.","Add parameter set 'GetViaIdentity' back to cmdlet 'Get-AzVMRunCommand'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1050","The parameter set '__AllParameterSets' for cmdlet 'Get-AzVMRunCommand' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'Get-AzVMRunCommand'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1020","The cmdlet 'Get-AzVMRunCommand' no longer has output type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IRunCommandDocument'.","Make cmdlet 'Get-AzVMRunCommand' return type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IRunCommandDocument'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1020","The cmdlet 'Get-AzVMRunCommand' no longer has output type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IVirtualMachineRunCommand'.","Make cmdlet 'Get-AzVMRunCommand' return type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IVirtualMachineRunCommand'." +"Az.Compute","Get-AzVMRunCommand","Get-AzVMRunCommand","0","1020","The cmdlet 'Get-AzVMRunCommand' no longer has output type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IRunCommandDocumentBase'.","Make cmdlet 'Get-AzVMRunCommand' return type 'Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IRunCommandDocumentBase'." \ No newline at end of file