New-AzConnectedMachineRunCommand

The operation to Create a run command.

Syntax

New-AzConnectedMachineRunCommand
   -MachineName <String>
   -ResourceGroupName <String>
   -RunCommandName <String>
   [-SubscriptionId <String>]
   -Location <String>
   [-AsyncExecution]
   [-ErrorBlobManagedIdentityClientId <String>]
   [-ErrorBlobManagedIdentityObjectId <String>]
   [-ErrorBlobUri <String>]
   [-OutputBlobManagedIdentityClientId <String>]
   [-OutputBlobManagedIdentityObjectId <String>]
   [-OutputBlobUri <String>]
   [-Parameter <IRunCommandInputParameter[]>]
   [-ProtectedParameter <IRunCommandInputParameter[]>]
   [-RunAsPassword <String>]
   [-RunAsUser <String>]
   [-ScriptUriManagedIdentityClientId <String>]
   [-ScriptUriManagedIdentityObjectId <String>]
   [-SourceCommandId <String>]
   [-SourceScript <String>]
   [-SourceScriptUri <String>]
   [-Tag <Hashtable>]
   [-TimeoutInSecond <Int32>]
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzConnectedMachineRunCommand
   -MachineName <String>
   -ResourceGroupName <String>
   -RunCommandName <String>
   [-SubscriptionId <String>]
   -Location <String>
   [-AsyncExecution]
   [-ErrorBlobManagedIdentityClientId <String>]
   [-ErrorBlobManagedIdentityObjectId <String>]
   [-ErrorBlobUri <String>]
   [-OutputBlobManagedIdentityClientId <String>]
   [-OutputBlobManagedIdentityObjectId <String>]
   [-OutputBlobUri <String>]
   [-Parameter <IRunCommandInputParameter[]>]
   [-ProtectedParameter <IRunCommandInputParameter[]>]
   [-RunAsPassword <String>]
   [-RunAsUser <String>]
   [-ScriptUriManagedIdentityClientId <String>]
   [-ScriptUriManagedIdentityObjectId <String>]
   [-SourceCommandId <String>]
   [-SourceScript <String>]
   [-SourceScriptUri <String>]
   [-Tag <Hashtable>]
   [-TimeoutInSecond <Int32>]
   [-ScriptLocalPath <String>]
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzConnectedMachineRunCommand
   -MachineName <String>
   -ResourceGroupName <String>
   -RunCommandName <String>
   [-SubscriptionId <String>]
   -JsonString <String>
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzConnectedMachineRunCommand
   -MachineName <String>
   -ResourceGroupName <String>
   -RunCommandName <String>
   [-SubscriptionId <String>]
   -JsonFilePath <String>
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzConnectedMachineRunCommand
   -MachineName <String>
   -ResourceGroupName <String>
   -RunCommandName <String>
   [-SubscriptionId <String>]
   -RunCommandProperty <IMachineRunCommand>
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzConnectedMachineRunCommand
   -RunCommandName <String>
   -MachineInputObject <IConnectedMachineIdentity>
   -Location <String>
   [-AsyncExecution]
   [-ErrorBlobManagedIdentityClientId <String>]
   [-ErrorBlobManagedIdentityObjectId <String>]
   [-ErrorBlobUri <String>]
   [-OutputBlobManagedIdentityClientId <String>]
   [-OutputBlobManagedIdentityObjectId <String>]
   [-OutputBlobUri <String>]
   [-Parameter <IRunCommandInputParameter[]>]
   [-ProtectedParameter <IRunCommandInputParameter[]>]
   [-RunAsPassword <String>]
   [-RunAsUser <String>]
   [-ScriptUriManagedIdentityClientId <String>]
   [-ScriptUriManagedIdentityObjectId <String>]
   [-SourceCommandId <String>]
   [-SourceScript <String>]
   [-SourceScriptUri <String>]
   [-Tag <Hashtable>]
   [-TimeoutInSecond <Int32>]
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzConnectedMachineRunCommand
   -RunCommandName <String>
   -MachineInputObject <IConnectedMachineIdentity>
   -RunCommandProperty <IMachineRunCommand>
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzConnectedMachineRunCommand
   -InputObject <IConnectedMachineIdentity>
   -Location <String>
   [-AsyncExecution]
   [-ErrorBlobManagedIdentityClientId <String>]
   [-ErrorBlobManagedIdentityObjectId <String>]
   [-ErrorBlobUri <String>]
   [-OutputBlobManagedIdentityClientId <String>]
   [-OutputBlobManagedIdentityObjectId <String>]
   [-OutputBlobUri <String>]
   [-Parameter <IRunCommandInputParameter[]>]
   [-ProtectedParameter <IRunCommandInputParameter[]>]
   [-RunAsPassword <String>]
   [-RunAsUser <String>]
   [-ScriptUriManagedIdentityClientId <String>]
   [-ScriptUriManagedIdentityObjectId <String>]
   [-SourceCommandId <String>]
   [-SourceScript <String>]
   [-SourceScriptUri <String>]
   [-Tag <Hashtable>]
   [-TimeoutInSecond <Int32>]
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzConnectedMachineRunCommand
   -InputObject <IConnectedMachineIdentity>
   -RunCommandProperty <IMachineRunCommand>
   [-DefaultProfile <PSObject>]
   [-AsJob]
   [-NoWait]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The operation to Create a run command.

Examples

Example 1: Create a run-command for a machine

New-AzConnectedMachineRunCommand -ResourceGroupName "az-sdk-test" -Location "eastus2euap" -SourceScript "Write-Host Hello World!" -RunCommandName "myRunCommand3" -MachineName "testmachine" -SubscriptionId "e6fe6705-4c9c-4b54-81d2-e455780e20b8"

AsyncExecution                    : False
ErrorBlobManagedIdentityClientId  :
ErrorBlobManagedIdentityObjectId  :
ErrorBlobUri                      :
Id                                : /subscriptions/e6fe6705-4c9c-4b54-81d2-e455780e20b8/resourceGroups/az-sdk-test/prov
                                    iders/Microsoft.HybridCompute/machines/testmachine/runcommands/myRunCommand3
InstanceViewEndTime               : 12/5/2023 7:27:26 PM
InstanceViewError                 :
InstanceViewExecutionMessage      : RunCommand script execution completed
InstanceViewExecutionState        : Succeeded
InstanceViewExitCode              : 0
InstanceViewOutput                : Hello World!
InstanceViewStartTime             : 12/5/2023 7:27:24 PM
InstanceViewStatuses              :
Location                          : eastus2euap
Name                              : myRunCommand3
OutputBlobManagedIdentityClientId :
OutputBlobManagedIdentityObjectId :
OutputBlobUri                     :
Parameter                         :
ProtectedParameter                :
ProvisioningState                 : Succeeded
ResourceGroupName                 : az-sdk-test
RunAsPassword                     :
RunAsUser                         :
ScriptUriManagedIdentityClientId  :
ScriptUriManagedIdentityObjectId  :
SourceCommandId                   :
SourceScript                      : Write-Host Hello World!
SourceScriptUri                   :
SystemDataCreatedAt               :
SystemDataCreatedBy               :
SystemDataCreatedByType           :
SystemDataLastModifiedAt          :
SystemDataLastModifiedBy          :
SystemDataLastModifiedByType      :
Tag                               : {
                                    }
TimeoutInSecond                   : 0
Type                              : Microsoft.HybridCompute/machines/runcommands

Create a run-command for a machine

Parameters

-AsJob

Run the command as a job

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

-AsyncExecution

Optional. If set to true, provisioning will complete as soon as script starts and will not wait for script to complete.

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.

Type:PSObject
Aliases:AzureRMContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ErrorBlobManagedIdentityClientId

Client Id (GUID value) of the user-assigned managed identity. ObjectId should not be used if this is provided.

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

-ErrorBlobManagedIdentityObjectId

Object Id (GUID value) of the user-assigned managed identity. ClientId should not be used if this is provided.

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

-ErrorBlobUri

Specifies the Azure storage blob where script error stream will be uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to provide the VM access to the blob. Refer errorBlobManagedIdentity parameter.

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

-InputObject

Identity Parameter

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

-JsonFilePath

Path of Json file supplied to the Create operation

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

-JsonString

Json string supplied to the Create operation

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

-Location

The geo-location where the resource lives

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

-MachineInputObject

Identity Parameter

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

-MachineName

The name of the hybrid machine.

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

-NoWait

Run the command asynchronously

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

-OutputBlobManagedIdentityClientId

Client Id (GUID value) of the user-assigned managed identity. ObjectId should not be used if this is provided.

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

-OutputBlobManagedIdentityObjectId

Object Id (GUID value) of the user-assigned managed identity. ClientId should not be used if this is provided.

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

-OutputBlobUri

Specifies the Azure storage blob where script output stream will be uploaded. Use a SAS URI with read, append, create, write access OR use managed identity to provide the VM access to the blob. Refer outputBlobManagedIdentity parameter.

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

-Parameter

The parameters used by the script.

Type:IRunCommandInputParameter[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ProtectedParameter

The parameters used by the script.

Type:IRunCommandInputParameter[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

The name of the resource group. The name is case insensitive.

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

-RunAsPassword

Specifies the user account password on the machine when executing the run command.

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

-RunAsUser

Specifies the user account on the machine when executing the run command.

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

-RunCommandName

The name of the run command.

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

-RunCommandProperty

Describes a Run Command

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

-ScriptLocalPath

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

-ScriptUriManagedIdentityClientId

Client Id (GUID value) of the user-assigned managed identity. ObjectId should not be used if this is provided.

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

-ScriptUriManagedIdentityObjectId

Object Id (GUID value) of the user-assigned managed identity. ClientId should not be used if this is provided.

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

-SourceCommandId

Specifies the commandId of predefined built-in script.

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

-SourceScript

Specifies the script content to be executed on the machine.

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

-SourceScriptUri

Specifies the script download location. It can be either SAS URI of an Azure storage blob with read access or public URI.

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

-SubscriptionId

The ID of the target subscription.

Type:String
Position:Named
Default value:(Get-AzContext).Subscription.Id
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Tag

Resource tags.

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

-TimeoutInSecond

The timeout in seconds to execute the run command.

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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

IConnectedMachineIdentity

IMachineRunCommand

Outputs

IMachineRunCommand