< Back

Set-AzureRmVirtualNetworkPeering

Tue Jan 29, 2019 9:58 pm

NAME Set-AzureRmVirtualNetworkPeering



SYNOPSIS

Configures a virtual network peering.





SYNTAX

Set-AzureRmVirtualNetworkPeering [-AsJob] [-DefaultProfile <IAzureContextContainer>] -VirtualNetworkPeering <PSVirtualNetworkPeering>

[<CommonParameters>]





DESCRIPTION

The Set-AzureRmVirtualNetworkPeering cmdlet configures a virtual network peering.





PARAMETERS

-AsJob [<SwitchParameter>]

Run cmdlet in the background



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-DefaultProfile <IAzureContextContainer>

The credentials, account, tenant, and subscription used for communication with azure.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-VirtualNetworkPeering <PSVirtualNetworkPeering>

Specifies the virtual network peering.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

PSVirtualNetworkPeering

Parameter 'VirtualNetworkPeering' accepts value of type 'PSVirtualNetworkPeering' from the pipeline





OUTPUTS

Microsoft.Azure.Commands.Network.Models.PSVirtualNetworkPeering







NOTES









Example 1: Change forwarded traffic configuration of a virtual network peering



# Get the virtual network peering you want to update information for

Get-AzureRmVirtualNetworkPeering -VirtualNetworkName "myVnet1" -ResourceGroupName "ResourceGroup" -Name "myVnet1ToMyVnet2"



# Change value of AllowForwardedTraffic property

$myVnet1ToMyVnet2.AllowForwardedTraffic = $True



# Update the peering with changes made

Set-AzureRmVirtualNetworkPeering -VirtualNetworkPeering $myVnet1ToMyVnet2









Example 2: Change virtual network access of a virtual network peering



# Get the virtual network peering

$myVnet1TomyVnet2 = Get-AzureRmVirtualNetworkPeering -VirtualNetworkName "myVnet1" -ResourceGroupName "myResourceGroup" -Name "myVnet1TomyVnet2"



# Change AllowVirtualNetworkAccess property

$myVnet1TomyVnet2.AllowVirtualNetworkAccess = $False



# Update virtual network peering

Set-AzureRmVirtualNetworkPeering -VirtualNetworkPeering $myVnet1TomyVnet2









Example 3: Change gateway transit property configuration of a virtual network peering



# Get the virtual network peering

$myVnet1TomyVnet2 = Get-AzureRmVirtualNetworkPeering -VirtualNetworkName "myVnet1" -ResourceGroupName "myResourceGroup" -Name "myVnet1TomyVnet2"



# Change AllowGatewayTransit property

$myVnet1TomyVnet2.AllowGatewayTransit = $True



# Update the virtual network peering

Set-AzureRmVirtualNetworkPeering -VirtualNetworkPeering $myVnet1TomyVnet2









Example 4: Use remote gateways in virtual network peering



# Get the virtual network peering

$myVnet1TomyVnet2 = Get-AzureRmVirtualNetworkPeering -VirtualNetworkName "myVnet1" -ResourceGroupName "ResourceGroup001" -Name "myVnet1TomyVnet2"



# Change the UseRemoteGateways property

$myVnet1TomyVnet2.UseRemoteGateways = $True



# Update the virtual network peering

Set-AzureRmVirtualNetworkPeering -VirtualNetworkPeering $LinkToVNet2



By changing this property to $True, your peer's VNet gateway can be used. However, the peer VNet must have a gateway configured and

AllowGatewayTransit must have a value of $True.



This property cannot be used if a gateway has already been configured.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... orkpeering

Add-AzureRmVirtualNetworkPeering

Get-AzureRmVirtualNetworkPeering

Remove-AzureRmVirtualNetworkPeering