Freigeben über


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-07-01

URI Parameters

Name In Required Type Description
commandId
path True

string

The command id.

location
path True

string

The location upon which run commands is queried.

Regex pattern: ^[-\w\._]+$

subscriptionId
path True

string

Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.

api-version
query True

string

Client Api Version.

Responses

Name Type Description
200 OK

RunCommandDocument

OK

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-07-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
OperatingSystemTypes

The Operating System type.

RunCommandDocument

Describes the properties of a Run Command.

RunCommandParameterDefinition

Describes the properties of a run command parameter.

OperatingSystemTypes

The Operating System type.

Name Type Description
Linux

string

Windows

string

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 Default value Description
defaultValue

string

The run command parameter default value.

name

string

The run command parameter name.

required

boolean

False

The run command parameter required.

type

string

The run command parameter type.