0

I have created a Powershell script that allows me to move resources in a DEV subscription to a resource group in a PROD subscription.

When I run the script: it runs and runs but does not stop so I stop the execution however when I look in Azure my resources have been moved.

Do you know how I can fix the problem ?

Here is the script

$resources = Get-AzResource -Name * -ResourceGroupName "Name"
Move-AzResource -DestinationResourceGroupName "Test" -DestinationSubscriptionId "ID" -ResourceId $resources.Id -Force

I looked in the Azure documentation but couldn't find anything : Link : https://learn.microsoft.com/en-us/powershell/module/az.resources/move-azresource?view=azps-9.4.0

Charline
  • 11
  • 1

1 Answers1

0

After reproducing from my end, I could see the same but after sometime I see it is getting stopped.

The lock can last for a maximum of four hours, but most moves complete in much less time.

It is just that the source and destination are getting locked during the move operation for a certain period of time depending upon the type of the resource. You can refer this MSFT Documentation.

During execution: enter image description here

After execution: enter image description here

As the Move-AzResource command returns a Boolean value to know if the transfer has completed you can include in an if else condition having Write-Output with related message in it.

SwethaKandikonda
  • 7,513
  • 2
  • 4
  • 18