< Back
Invoke-AzureRmVMRunCommand
Post
NAME Invoke-AzureRmVMRunCommand
SYNOPSIS
Run command on the VM.
SYNTAX
Invoke-AzureRmVMRunCommand [-ResourceGroupName] <String> [-VMName] <String> [-AsJob] -CommandId <String> [-DefaultProfile
<IAzureContextContainer>] [-Parameter <Hashtable>] [-ScriptPath <String>] [-Confirm] [-WhatIf] [<CommonParameters>]
Invoke-AzureRmVMRunCommand [-VM] <PSVirtualMachine> [-AsJob] -CommandId <String> [-DefaultProfile <IAzureContextContainer>] [-Parameter
<Hashtable>] [-ScriptPath <String>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
Invoke a run command on the VM.
PARAMETERS
-AsJob [<SwitchParameter>]
Run cmdlet in the background and return a Job to track progress.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-CommandId <String>
The run command id.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Parameter <Hashtable>
The run command parameters.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ResourceGroupName <String>
The name of the resource group.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ScriptPath <String>
Path of the script to be executed. When this value is given, the given script will override the default script of the command.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-VM <PSVirtualMachine>
The PS virtual Machine Object.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName, ByValue)
Accept wildcard characters? false
-VMName <String>
The name of the virtual machine.
Required? true
Position? 2
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String
Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine
OUTPUTS
Microsoft.Azure.Commands.Compute.Automation.Models.PSRunCommandResult
NOTES
Example 1
PS C:\\> Invoke-AzureRmVMRunCommand -ResourceGroupName 'rgname' -Name 'vmname' -CommandId 'RunPowerShellScript' -ScriptPath 'sample.ps1' -Parameter
@{"arg1" = "var1";"arg2" = "var2"}
Invoke a run command of RunPowerShellScript with overriding the script 'sample.ps1' and the parameters on the VM of 'vmname' in resource group
'rgname'.
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... runcommand
SYNOPSIS
Run command on the VM.
SYNTAX
Invoke-AzureRmVMRunCommand [-ResourceGroupName] <String> [-VMName] <String> [-AsJob] -CommandId <String> [-DefaultProfile
<IAzureContextContainer>] [-Parameter <Hashtable>] [-ScriptPath <String>] [-Confirm] [-WhatIf] [<CommonParameters>]
Invoke-AzureRmVMRunCommand [-VM] <PSVirtualMachine> [-AsJob] -CommandId <String> [-DefaultProfile <IAzureContextContainer>] [-Parameter
<Hashtable>] [-ScriptPath <String>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
Invoke a run command on the VM.
PARAMETERS
-AsJob [<SwitchParameter>]
Run cmdlet in the background and return a Job to track progress.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-CommandId <String>
The run command id.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Parameter <Hashtable>
The run command parameters.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ResourceGroupName <String>
The name of the resource group.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ScriptPath <String>
Path of the script to be executed. When this value is given, the given script will override the default script of the command.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-VM <PSVirtualMachine>
The PS virtual Machine Object.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName, ByValue)
Accept wildcard characters? false
-VMName <String>
The name of the virtual machine.
Required? true
Position? 2
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String
Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine
OUTPUTS
Microsoft.Azure.Commands.Compute.Automation.Models.PSRunCommandResult
NOTES
Example 1
PS C:\\> Invoke-AzureRmVMRunCommand -ResourceGroupName 'rgname' -Name 'vmname' -CommandId 'RunPowerShellScript' -ScriptPath 'sample.ps1' -Parameter
@{"arg1" = "var1";"arg2" = "var2"}
Invoke a run command of RunPowerShellScript with overriding the script 'sample.ps1' and the parameters on the VM of 'vmname' in resource group
'rgname'.
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... runcommand