Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Compute/Compute/Az.Compute.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 = '*'
Expand Down
1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions src/Compute/Compute/Manual/PSVirtualMachineRunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> Tags { get; set; }
public VirtualMachineRunCommandScriptSource Source { get; set; }
public IList<RunCommandInputParameter> Parameters { get; set; }
public IList<RunCommandInputParameter> ProtectedParameters { get; set; }
Expand Down
15 changes: 15 additions & 0 deletions src/Compute/Compute/Models/PSVirtualMachineRunCommandList.cs
Original file line number Diff line number Diff line change
@@ -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<PSVirtualMachineRunCommand>(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -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<VirtualMachineRunCommand, PSVirtualMachineRunCommand>(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<PSVirtualMachineRunCommand>();
foreach (var r in resultList)
{
psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map<VirtualMachineRunCommand, PSVirtualMachineRunCommandList>(r));
}
WriteObject(psObject);
}
});
}
}
}
135 changes: 18 additions & 117 deletions src/Compute/Compute/help/Get-AzVMRunCommand.md
Original file line number Diff line number Diff line change
@@ -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 <String> [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
[<CommonParameters>]
```

### Get
```
Get-AzVMRunCommand -CommandId <String> -Location <String> [-SubscriptionId <String[]>]
[-DefaultProfile <PSObject>] [<CommonParameters>]
```

### List1
```
Get-AzVMRunCommand [-SubscriptionId <String[]>] -ResourceGroupName <String> -VMName <String> [-Expand <String>]
[-DefaultProfile <PSObject>] [<CommonParameters>]
```

### Get1
```
Get-AzVMRunCommand [-SubscriptionId <String[]>] -ResourceGroupName <String> -RunCommandName <String>
-VMName <String> [-Expand <String>] [-DefaultProfile <PSObject>] [<CommonParameters>]
```

### GetViaIdentity
```
Get-AzVMRunCommand -InputObject <IComputeIdentity> [-DefaultProfile <PSObject>] [<CommonParameters>]
Get-AzVMRunCommand -ResourceGroupName <String> -VMName <String> [-RunCommandName <String>] [-Expand <String>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -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.

Expand All @@ -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
Expand All @@ -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
```

Expand All @@ -157,44 +74,28 @@ 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
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
```

Expand All @@ -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
```

Expand Down
Loading