Share via


Move-AzureResource

Move-AzureResource

Moves resources to a different resource group.

Syntax

Parameter Set: BySubscriptionId
Move-AzureResource -DestinationResourceGroupName <String> -ResourceId <String[]> [-DestinationSubscriptionId <String> ] [-Force] [-PassThru] [-Profile <AzureProfile> ] [ <CommonParameters>]

Parameter Set: BySubscriptionName
Move-AzureResource -DestinationResourceGroupName <String> -DestinationSubscriptionName <String> -ResourceId <String[]> [-Force] [-PassThru] [-Profile <AzureProfile> ] [ <CommonParameters>]

Detailed Description

The Move-AzureResource cmdlet moves Azure resources to a different resource group. The destination resource group can be in a different subscription.

Parameters

-DestinationResourceGroupName<String>

Specifies the name of the resource group into which this cmdlet moves resources.

Aliases

TargetResourceGroup

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DestinationSubscriptionId<String>

Specifies the ID of the subscription into which this cmdlet moves resources.

Aliases

Id,SubscriptionId

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-DestinationSubscriptionName<String>

Specifies the name of the subscription into which this cmdlet moves resources.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-Force

Forces the command to run without asking for user confirmation.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PassThru

Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Profile<AzureProfile>

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ResourceId<String[]>

Specifies an array of IDs of resources that this cmdlet moves to a different resource group.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true(ByValue,ByPropertyName)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

Example 1: Move a resource

The first command gets the website resource named ContosoLabWeb by using the Get-AzureResource cmdlet. The command stores the result in the $Resource variable.

The second command moves the resource to the resource group named ContosoProductionRG The command specifies the resource by using the ResourceId property.

$Resource = Get-AzureResource -Name "ContosoLabWeb" -ResourceGroupName "ContosoLabsRG" -ResourceType "Microsoft.Web/sites" -ApiVersion 2015-04-01
PS C:\> Move-AzureResource -ResourceId $Resource.ResourceId -DestinationResourceGroupName "ContosoProductionRG"

Get-AzureResource

New-AzureResource

Remove-AzureResource

Set-AzureResource