Editar

Compartilhar via


Get-AzVMRunCommand

Gets a specific Run Command or a list of Run Commands for a Virtual Machine

Syntax

Get-AzVMRunCommand
   -ResourceGroupName <String>
   -VMName <String>
   [-RunCommandName <String>]
   [-Expand <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

Gets specific run command for a subscription in a location.

Examples

Example 1: Get a Run Command for VM.

Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM -RunCommandName MyRunCommand

Get a Run Command for VM without Instance View.

Example 2: Get a Run Command for VM with Instance View

$x = Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM -RunCommandName MyRunCommand -Expand InstanceView
$x.InstanceView

ExecutionState   : Succeeded
ExecutionMessage :
ExitCode         : 0
Output           :     Directory: C:\


                   Mode                 LastWriteTime         Length Name
                   ----                 -------------         ------ ----
                   -a----        10/27/2022   9:10 PM              0 HelloWorld2022-10-27T21.10.54.9266231+00.00.txt


Error            :
StartTime        : 10/27/2022 9:10:52 PM
EndTime          : 10/27/2022 9:10:55 PM
Statuses         :

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.

Example 3: Get all Run Commands for a VM

Get-AzVMRunCommand -ResourceGroupName MyRG -VMName MyVM

Get all Run Commands for a VM

Parameters

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Expand

The expand expression to apply on the operation. Possible value(s): InstanceView

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ResourceGroupName

Name of the resource group for the run command.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:True

-RunCommandName

The name of the virtual machine run command.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-VMName

The name of the virtual machine containing the run command.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

String

Outputs

PSVirtualMachineRunCommand