Created
September 29, 2017 15:22
-
-
Save bmoore-msft/51e098b01f1947aa529ebbfff0ee255c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
#This script will call the validateMoveResources api to see if resources can be moved (before you try to actually move them) | |
# | |
$subscriptionId = '...' | |
$sourceResourceGroup = 'SourceGroup' | |
$destinationResourceGroup = 'DestGroup' #must exist | |
# Create an array of resourceIds that are to be moved | |
$resourcesToMove = @( | |
"/subscriptions/$subscriptionId/resourceGroups/$sourceResourceGroup/providers/Microsoft.Network/publicIPAddresses/somePublicIp" | |
"/subscriptions/$subscriptionId/resourceGroups/$sourceResourceGroup/providers/Microsoft.Storage/storageAccounts/somestorageaccount" | |
) | |
# Create a hashtable for the request body of the api | |
$params = New-Object -TypeName Hashtable | |
$params.Add('resources', $resourcesToMove) | |
$params.Add('targetResourceGroup', "/subscriptions/$subscriptionId/resourceGroups/$destinationResourceGroup") | |
# This api will return nothing for success, add the -Debug switch to see the entire REST conversation | |
Invoke-AzureRmResourceAction -Action validateMoveResources -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$sourceResourceGroup" -Parameters $params -Debug |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment