Introduction

Azure Virtual Network Gateways enable secure, cross-premises connectivity through VPN tunnels. Understanding the connection statistics of your VPN clients is crucial for monitoring network health, troubleshooting connectivity issues, and ensuring optimal performance. The following PowerShell cmdlets provide granular access to this vital information.

Key Cmdlets

Get-AzVpnClientConnectionStatistics

Retrieves the VPN client connection statistics for a specified Virtual Network Gateway.

Syntax

Get-AzVpnClientConnectionStatistics -VirtualNetworkGatewayName <String> [-ResourceGroupName <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]

Parameters

Name Description Required
-VirtualNetworkGatewayName The name of the Virtual Network Gateway. Yes
-ResourceGroupName The name of the resource group. No
-DefaultProfile The Azure context to use for this command. No

Example Usage

# Get connection statistics for a VPN gateway in the 'MyResourceGroup' resource group
Get-AzVpnClientConnectionStatistics -VirtualNetworkGatewayName "myVpnGateway" -ResourceGroupName "MyResourceGroup"

Output

The cmdlet returns an object containing the following properties:

Get-AzVpnClientConnectionStatisticsPerUser

Retrieves the VPN client connection statistics for a specific user connected to a Virtual Network Gateway.

Syntax

Get-AzVpnClientConnectionStatisticsPerUser -VirtualNetworkGatewayName <String> -User <String> [-ResourceGroupName <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]

Parameters

Name Description Required
-VirtualNetworkGatewayName The name of the Virtual Network Gateway. Yes
-User The username of the VPN client. Yes
-ResourceGroupName The name of the resource group. No
-DefaultProfile The Azure context to use for this command. No

Example Usage

# Get connection statistics for a specific user
Get-AzVpnClientConnectionStatisticsPerUser -VirtualNetworkGatewayName "myVpnGateway" -ResourceGroupName "MyResourceGroup" -User "jane.doe@example.com"

Output

Returns an object containing detailed connection statistics for the specified user, including their IP address, connection duration, data transfer, and connection state.

Important Considerations

Ensure you have the appropriate Azure permissions to access and query Virtual Network Gateway resources. Use the Connect-AzAccount cmdlet to authenticate with your Azure subscription before running these commands.

Related Cmdlets

For more advanced network management and monitoring in Azure, explore the full Azure PowerShell documentation.