Upravit

Sdílet prostřednictvím


Get-AzVmssVMRunCommand

The operation to get the VMSS VM run command.

Syntax

Get-AzVmssVMRunCommand
   -ResourceGroupName <String>
   -VMScaleSetName <String>
   -InstanceId <String>
   [-RunCommandName <String>]
   [-Expand <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The operation to get the VMSS VM run command.

Examples

Example 1: Get a Run Command for VMSS VM instance

Get-AzVmssVMRunCommand  -ResourceGroupName MyRG0 -VMScaleSetName MyVMSS -InstanceId 0 -RunCommandName MyRunCommand

Get a Run Command for VM without Instance View.

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

$x = Get-AzVmssVMRunCommand  -ResourceGroupName MyRG0 -VMScaleSetName MyVMSS -InstanceId 0 -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 VMSS VM instance

Get-AzVmssVMRunCommand -ResourceGroupName MyRG -VMScaleSetName MyVMSS -InstanceId 1

Get list of 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. For instance view, pass in "InstanceView".

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

-InstanceId

Instance ID of the virtual machine for from the VM scale set.

Type:String
Position:Named
Default value:None
Required:True
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

Name of the run command.

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

-VMScaleSetName

Name of the virtual machine scale set of the run command.

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

Inputs

String

Outputs

PSVirtualMachineRunCommand