Edit

Share via


Set-AzureVNetGateway

Enables or disables a VPN gateway for an Azure virtual network.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

Connect (Default)

Set-AzureVNetGateway
    -VNetName <String>
    -LocalNetworkSiteName <String>
    [-Connect]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

Disconnect

Set-AzureVNetGateway
    -VNetName <String>
    -LocalNetworkSiteName <String>
    [-Disconnect]
    [-Profile <AzureSMProfile>]
    [<CommonParameters>]

Description

The Set-AzureVNetGateway cmdlet enables or disables a virtual private network (VPN) gateway for an Azure virtual network. A virtual network gateway is a VPN endpoint for connecting to a virtual network. Specify the Connect or Disconnect parameter to enable or disable the VPN connection between an on-premises local network site and a virtual network.

Examples

Example 1: Enable a virtual network gateway for a virtual network

PS C:\> Set-AzureVNetGateway -Connect -VnetName "ContosoProdNet" -LocalNetworkSiteName "ContosoBranchOffice"

This command enables the virtual network gateway between the Azure virtual network named ContosoProdNet and the VPN device for the local network site named ContosoBranchOffice.

Example 2: Disable a virtual network gateway for a virtual network

PS C:\> Set-AzureVNetGateway -Disconnect -VnetName "ContosoProdNet" -LocalNetworkSiteName "ContosoBranchOffice"

This command disables the virtual network gateway between the Azure virtual network named ContosoProdNet and the VPN device for the local network site named ContosoBranchOffice.

Parameters

-Connect

Indicates that this cmdlet enables the VPN connection between a virtual network and a local network site.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Connect
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Disconnect

Indicates that this cmdlet disables the VPN connection between a virtual network and a local network site.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Disconnect
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-LocalNetworkSiteName

Specifies the name of the on-premises local network site for which this cmdlet enables or disables the VPN connection.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Profile

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Parameter properties

Type:AzureSMProfile
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VNetName

Specifies the virtual network for which this cmdlet enables or disables the VPN connection.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.