hubspoke-across-tenants
#declare variables $subscriptionTenantA = "subscriptionID" $vNetTenantA = "vNet" $vnetResourceGroupTenantA = "vNetResourceGroup" $subscriptionTenantB = "subscriptionID" $vNetTenantB = "vNet" $vnetResourceGroupTenantB = "vNetResourceGroup" #connect to AzureRM Connect-AzAccount #select subscription in Tenant A Select-AzSubscription -Subscription $subscriptionTenantA #Activate GatewayTransit on Hub network $peerSiteA = Get-AzVirtualNetworkPeering -ResourceGroupName $vnetResourceGroupTenantA -VirtualNetworkName $vNetTenantA $peerSiteA.AllowGatewayTransit = $true Set-AzVirtualNetworkPeering -VirtualNetworkPeering $peerSiteA #select subscription in Tenant B Select-AzureRmSubscription -Subscription $subscriptionTenantB #use Remote Gateways on Spoke network $peerSiteB = Get-AzVirtualNetworkPeering -ResourceGroupName $vnetResourceGroupTenantB -VirtualNetworkName $vNetTenantB $peerSiteB.UseRemoteGateways = $true Set-AzVirtualNetworkPeering -VirtualNetworkPeering $peerSiteB