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=2025-04-01
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
command
|
path | True |
string |
Specifies a commandId of predefined built-in script. Command IDs available for Linux are listed at https://aka.ms/RunCommandManagedLinux#available-commands, Windows at https://aka.ms/RunCommandManagedWindows#available-commands. |
|
location
|
path | True |
string minLength: 1 |
The name of Azure region. |
|
subscription
|
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 |
Azure operation completed successfully. |
|
| Other Status Codes |
An unexpected error response. |
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
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 |
|---|---|
|
Api |
Api error. |
|
Api |
Api error base. |
|
Cloud |
An error response from the Compute service. |
|
Inner |
Inner error details. |
|
Operating |
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. |
|
Run |
Describes the properties of a Run Command. |
|
Run |
Describes the properties of a run command parameter. |
ApiError
Api error.
| Name | Type | Description |
|---|---|---|
| code |
string |
The error code. |
| details |
The Api error details |
|
| 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 |
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 |
The Operating System type. |
|
| parameters |
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. |