Share via


Virtual Machine Run Commands - Get

Gets specific run command for a subscription in a location.

GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}?api-version=2024-11-01

URI Parameters

Name In Required Type Description
commandId
path True

string

The command id.

location
path True

string

minLength: 1

The name of Azure region.

subscriptionId
path True

string

minLength: 1

The ID of the target subscription.

api-version
query True

string

minLength: 1

The API version to use for this operation.

Responses

Name Type Description
200 OK

RunCommandDocument

Azure operation completed successfully.

Media Types: "application/json", "text/json"

Other Status Codes

CloudError

An unexpected error response.

Media Types: "application/json", "text/json"

Security

azure_auth

Azure Active Directory OAuth2 Flow.

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

VirtualMachineRunCommandGet

Sample request

GET https://management.azure.com/subscriptions/24fb23e3-6ba3-41f0-9b6e-e41131d5d61e/providers/Microsoft.Compute/locations/SoutheastAsia/runCommands/RunPowerShellScript?api-version=2024-11-01

Sample response

{
  "script": [
    "param(",
    "    [string]$arg1,",
    "    [string]$arg2",
    ")",
    "Write-Host This is a sample script with parameters $arg1 $arg2"
  ],
  "parameters": [
    {
      "name": "arg1",
      "type": "string",
      "defaultValue": "value1"
    },
    {
      "name": "arg2",
      "type": "string",
      "defaultValue": "value2"
    }
  ],
  "$schema": "http://schema.management.azure.com/schemas/2016-11-17/runcommands.json",
  "id": "RunPowerShellScript",
  "osType": "Windows",
  "label": "Executes a PowerShell script",
  "description": "Custom multiline PowerShell script should be defined in script property. Optional parameters can be set in parameters property."
}

Definitions

Name Description
ApiError

Api error.

ApiErrorBase

Api error base.

CloudError

An error response from the Compute service.

InnerError

Inner error details.

OperatingSystemTypes

This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. Possible values are: Windows, Linux.

RunCommandDocument

Describes the properties of a Run Command.

RunCommandParameterDefinition

Describes the properties of a run command parameter.

ApiError

Api error.

Name Type Description
code

string

The error code.

details

ApiErrorBase[]

The Api error details

innererror

InnerError

The Api inner error

message

string

The error message.

target

string

The target of the particular error.

ApiErrorBase

Api error base.

Name Type Description
code

string

The error code.

message

string

The error message.

target

string

The target of the particular error.

CloudError

An error response from the Compute service.

Name Type Description
error

ApiError

Api error.

InnerError

Inner error details.

Name Type Description
errordetail

string

The internal error message or exception dump.

exceptiontype

string

The exception type.

OperatingSystemTypes

This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. Possible values are: Windows, Linux.

Value Description
Windows
Linux

RunCommandDocument

Describes the properties of a Run Command.

Name Type Description
$schema

string

The VM run command schema.

description

string

The VM run command description.

id

string

The VM run command id.

label

string

The VM run command label.

osType

OperatingSystemTypes

The Operating System type.

parameters

RunCommandParameterDefinition[]

The parameters used by the script.

script

string[]

The script to be executed.

RunCommandParameterDefinition

Describes the properties of a run command parameter.

Name Type Description
defaultValue

string

The run command parameter default value.

name

string

The run command parameter name.

required

boolean

The run command parameter required.

type

string

The run command parameter type.