Quick Tip: Listing your Shared key in Azure VPN with Multisite configuration

If you ever configured an Azure VPN, you may have used the trick of downloading the device script configuration from the portal to obtain the shared secret for your VPN device. However, if you have a multi-site configuration that procedure is not effective, since there are different secrets for each network. In that case, PowerShell to the rescue!


All you need to know is the name of you Azure VPN Gateway and run this (one liner) below. Make sure you are logged on to the Azure subscription containing the gateway (add-azureaccount) and that you’ve selected the right subscription (select-azuresubscription).


(Get-AzureVNetSite -VNetName “MyVPNGateway“).gatewaysites | foreach {Write-host “Local Site: $($_.name) Key: $((Get-AzureVNetGatewayKey -VNetName “MyVPNGateway” -LocalNetworkSiteName $_.Name).Value)” }


You’ll get then a list for each local site.

Easy. Quick. PowerShell.


Hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *