swagger: "2.0"
schemes:
  - https
host: management.azure.com
info:
  description: The Run Commands Client.
  title: RunCommandsClient
  version: 2019-03-01
  x-apisguru-categories:
    - cloud
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_assets.onestore.ms_cdnfiles_onestorerolling-1606-01000_shell_v3_images_logo_microsoft.png
  x-origin:
    - format: swagger
      url: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/compute/resource-manager/Microsoft.Compute/stable/2019-03-01/runCommands.json
      version: "2.0"
  x-preferred: true
  x-providerName: azure.com
  x-serviceName: compute-runCommands
  x-tags:
    - Azure
    - Microsoft
consumes:
  - application/json
  - text/json
produces:
  - application/json
  - text/json
securityDefinitions:
  azure_auth:
    authorizationUrl: https://login.microsoftonline.com/common/oauth2/authorize
    description: Azure Active Directory OAuth2 Flow
    flow: implicit
    scopes:
      user_impersonation: impersonate your user account
    type: oauth2
security:
  - azure_auth:
      - user_impersonation
parameters:
  ApiVersionParameter:
    description: Client Api Version.
    in: query
    name: api-version
    required: true
    type: string
  SubscriptionIdParameter:
    description: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
    in: path
    name: subscriptionId
    required: true
    type: string
paths:
  "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands":
    get:
      description: Lists all available run commands for a subscription in a location.
      operationId: VirtualMachineRunCommands_List
      parameters:
        - description: The location upon which run commands is queried.
          in: path
          name: location
          pattern: ^[-\w\._]+$
          required: true
          type: string
        - $ref: "#/parameters/ApiVersionParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/RunCommandListResult"
      tags:
        - VirtualMachineRunCommands
      x-ms-examples:
        VirtualMachineRunCommandList:
          parameters:
            api-version: 2019-03-01
            location: SoutheastAsia
            subscriptionId: subid
          responses:
            "200":
              body:
                value:
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Configure the machine to enable remote PowerShell.
                    id: EnableRemotePS
                    label: Enable remote PowerShell
                    osType: Windows
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Shows detailed information for the IP address, subnet mask and default gateway for each adapter bound to TCP/IP.
                    id: IPConfig
                    label: List IP configuration
                    osType: Windows
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Custom multiline PowerShell script should be defined in script property. Optional parameters can be set in parameters property.
                    id: RunPowerShellScript
                    label: Executes a PowerShell script
                    osType: Windows
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Custom multiline shell script should be defined in script property. Optional parameters can be set in parameters property.
                    id: RunShellScript
                    label: Executes a Linux shell script
                    osType: Linux
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Get the configuration of all network interfaces.
                    id: ifconfig
                    label: List network configuration
                    osType: Linux
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Checks if the local Administrator account is disabled, and if so enables it.
                    id: EnableAdminAccount
                    label: Enable administrator account
                    osType: Windows
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Reset built-in Administrator account password.
                    id: ResetAccountPassword
                    label: Reset built-in Administrator account password
                    osType: Windows
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Checks registry settings and domain policy settings. Suggests policy actions if machine is part of a domain or modifies the settings to default values.
                    id: RDPSettings
                    label: Verify RDP Listener Settings
                    osType: Windows
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Sets the default or user specified port number for Remote Desktop connections. Enables firewall rule for inbound access to the port.
                    id: SetRDPPort
                    label: Set Remote Desktop port
                    osType: Windows
                  - $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                    description: Removes the SSL certificate tied to the RDP listener and restores the RDP listerner security to default. Use this script if you see any issues with the certificate.
                    id: ResetRDPCert
                    label: Restore RDP Authentication mode to defaults
                    osType: Windows
      x-ms-pageable:
        nextLinkName: nextLink
  "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}":
    get:
      description: Gets specific run command for a subscription in a location.
      operationId: VirtualMachineRunCommands_Get
      parameters:
        - description: The location upon which run commands is queried.
          in: path
          name: location
          pattern: ^[-\w\._]+$
          required: true
          type: string
        - description: The command id.
          in: path
          name: commandId
          required: true
          type: string
        - $ref: "#/parameters/ApiVersionParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/RunCommandDocument"
      tags:
        - VirtualMachineRunCommands
      x-ms-examples:
        VirtualMachineRunCommandGet:
          parameters:
            api-version: 2019-03-01
            commandId: RunPowerShellScript
            location: SoutheastAsia
            subscriptionId: 24fb23e3-6ba3-41f0-9b6e-e41131d5d61e
          responses:
            "200":
              body:
                $schema: http://schema.management.azure.com/schemas/2016-11-17/runcommands.json
                description: Custom multiline PowerShell script should be defined in script property. Optional parameters can be set in parameters property.
                id: RunPowerShellScript
                label: Executes a PowerShell script
                osType: Windows
                parameters:
                  - defaultValue: value1
                    name: arg1
                    type: string
                  - defaultValue: value2
                    name: arg2
                    type: string
                script:
                  - param(
                  - "    [string]$arg1,"
                  - "    [string]$arg2"
                  - )
                  - Write-Host This is a sample script with parameters $arg1 $arg2
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand":
    post:
      description: Run command on a virtual machine in a VM scale set.
      operationId: VirtualMachineScaleSetVMs_RunCommand
      parameters:
        - description: The name of the resource group.
          in: path
          name: resourceGroupName
          required: true
          type: string
        - description: The name of the VM scale set.
          in: path
          name: vmScaleSetName
          required: true
          type: string
        - description: The instance ID of the virtual machine.
          in: path
          name: instanceId
          required: true
          type: string
        - description: Parameters supplied to the Run command operation.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/RunCommandInput"
        - $ref: "#/parameters/ApiVersionParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/RunCommandResult"
        "202":
          description: Accepted
      tags:
        - VirtualMachineScaleSetVMs
      x-ms-long-running-operation: true
      x-ms-long-running-operation-options:
        final-state-via: location
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand":
    post:
      description: Run command on the VM.
      operationId: VirtualMachines_RunCommand
      parameters:
        - description: The name of the resource group.
          in: path
          name: resourceGroupName
          required: true
          type: string
        - description: The name of the virtual machine.
          in: path
          name: vmName
          required: true
          type: string
        - description: Parameters supplied to the Run command operation.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/RunCommandInput"
        - $ref: "#/parameters/ApiVersionParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/RunCommandResult"
        "202":
          description: Accepted
      tags:
        - VirtualMachines
      x-ms-examples:
        VirtualMachineRunCommand:
          parameters:
            $top: 1
            api-version: 2019-03-01
            monitor: "true"
            parameters:
              commandId: RunPowerShellScript
            resourceGroupName: crptestar98131
            subscriptionId: 24fb23e3-6ba3-41f0-9b6e-e41131d5d61e
            vmName: vm3036
          responses:
            "200":
              body:
                value:
                  - code: ComponentStatus/StdOut/succeeded
                    displayStatus: Provisioning succeeded
                    level: Info
                    message: This is a sample script with parameters value1 value2
                  - code: ComponentStatus/StdErr/succeeded
                    displayStatus: Provisioning succeeded
                    level: Info
                    message: ""
            "202": {}
      x-ms-long-running-operation: true
      x-ms-long-running-operation-options:
        final-state-via: location
definitions:
  InstanceViewStatus:
    description: Instance view status.
    properties:
      code:
        description: The status code.
        type: string
      displayStatus:
        description: The short localizable label for the status.
        type: string
      level:
        description: The level code.
        enum:
          - Info
          - Warning
          - Error
        type: string
        x-ms-enum:
          modelAsString: false
          name: StatusLevelTypes
      message:
        description: The detailed status message, including for alerts and error messages.
        type: string
      time:
        description: The time of the status.
        format: date-time
        type: string
  RunCommandDocument:
    allOf:
      - $ref: "#/definitions/RunCommandDocumentBase"
    description: Describes the properties of a Run Command.
    properties:
      parameters:
        description: The parameters used by the script.
        items:
          $ref: "#/definitions/RunCommandParameterDefinition"
        type: array
      script:
        description: The script to be executed.
        items:
          type: string
        type: array
    required:
      - script
  RunCommandDocumentBase:
    description: Describes the properties of a Run Command metadata.
    properties:
      $schema:
        description: The VM run command schema.
        type: string
      description:
        description: The VM run command description.
        type: string
      id:
        description: The VM run command id.
        type: string
      label:
        description: The VM run command label.
        type: string
      osType:
        description: The Operating System type.
        enum:
          - Windows
          - Linux
        type: string
        x-ms-enum:
          modelAsString: false
          name: OperatingSystemTypes
    required:
      - $schema
      - id
      - osType
      - label
      - description
  RunCommandInput:
    description: Capture Virtual Machine parameters.
    properties:
      commandId:
        description: The run command id.
        type: string
      parameters:
        description: The run command parameters.
        items:
          $ref: "#/definitions/RunCommandInputParameter"
        type: array
      script:
        description: Optional. The script to be executed.  When this value is given, the given script will override the default script of the command.
        items:
          type: string
        type: array
    required:
      - commandId
  RunCommandInputParameter:
    description: Describes the properties of a run command parameter.
    properties:
      name:
        description: The run command parameter name.
        type: string
      value:
        description: The run command parameter value.
        type: string
    required:
      - name
      - value
  RunCommandListResult:
    description: The List Virtual Machine operation response.
    properties:
      nextLink:
        description: The uri to fetch the next page of run commands. Call ListNext() with this to fetch the next page of run commands.
        type: string
      value:
        description: The list of virtual machine run commands.
        items:
          $ref: "#/definitions/RunCommandDocumentBase"
        type: array
    required:
      - value
  RunCommandParameterDefinition:
    description: Describes the properties of a run command parameter.
    properties:
      defaultValue:
        description: The run command parameter default value.
        type: string
      name:
        description: The run command parameter name.
        type: string
      required:
        default: false
        description: The run command parameter required.
        type: boolean
      type:
        description: The run command parameter type.
        type: string
    required:
      - name
      - type
  RunCommandResult:
    properties:
      value:
        description: Run command operation response.
        items:
          $ref: "#/definitions/InstanceViewStatus"
        type: array
