Azure Pack–Migration of Services from Subscription to Subscription
Recently i had to migrate all VMs and vNets from one Owner to a new Owner. So i hab to move all Services from the Source Subscription to a new one.
Here is the script i used for that:
$vmmserver = Get-SCVMMServer -ComputerName roxvmm -ForOnBehalfOf $vmmserver | ft name,ActiveVMMNode, ForOnBehalfOf, UserRole -AutoSize $cloud = Get-SCCloud | where {$_.Name -eq "Tenant Cloud Gold"} #---------------- hier wird die Quelle definiert ---------------------------------- $subscriptionID = '25ea083d-04bf-459a-855d-caea72ea5078' #---------------- hier wird das Ziel definiert ---------------------------------- $subscriptionID_Destination = '3258e51a-ba2e-4b9d-9d74-5b10a9dd3d29' $owner_Destination = '[email protected]' $userRole_Destination = Get-SCUserRole | ? { $_.Name -like "*$subscriptionID_Destination" } $userRole_Destination | ft Name, ID, profile -AutoSize
So the Source and Destination variables are set.
Here is the Magic Login to the VMM:
#---------------- which VMs are in that subscription -------------------------- $VMs = Get-SCVirtualMachine -Cloud $cloud | ? { $_.UserRole -like "*$subscriptionID" } $VMs | ft name, cloudvmrolename, owner, selfserviceuserrole,UserRole -AutoSize
Set vNet Ownership:
# get all vNets the user owns $vNets = Get-SCVMNetwork | ? { $_.UserRole -like "*$subscriptionID" } $vNets | ft name -AutoSize # lets roll over all vNets in the array $vNets | foreach { Set-SCVMNetwork -VMNetwork $_ -Owner $owner_Destination -UserRole $userRole_Destination }
So vNet Ownership is set, now let’s do the Cloud Services and the VMs itself:
# lets roll over all VMs in the array $VMs | foreach { # we asume that it is a cloud service, so cloud service MUST change first $cloudservice = Get-CloudService -Name $_.CloudVmRoleName Set-CloudService $cloudservice -Owner $owner_Destination -UserRole $userRole_Destination # now just set new owner and role ;) Set-SCVirtualMachine $_ -Cloud $Cloud -Owner $owner_Destination -UserRole $userRole_Destination } # done ;)
I am running Azure Pack RU10 fully patched!
Please visit my Sponsor www.acpcloud.rocks