examples/_full.example.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Login-AzureAccount

$vNetGatewayName      = 'VNet1GW'
$resourceGroupName    = 'TestRG'
$pfxpassword          = Read-Host -AsSecureString
$exportPath           = 'c:\a'
$numberOfClientCerts = 20

$rootCert = New-AzureVPNRootCertificate -subject 'azureVPNRootCertTest'
$rootCert | Export-AzureVPNCertificate -cer -path $exportPath

$uploadRootCert = @{
                        VirtualNetworkGatewayname    = $vNetGatewayName
                        ResourceGroupName            = $resourceGroupName
                        VpnClientRootCertificateName = $rootCert.thumbPrint
                        PublicCertData               = Get-Content -Path $rootCert.Path
                   }

Add-AzureVpnClientRootCertificate @uploadRootCert

$count = 0

while($count -le $numberOfClientCerts)
{
    $clientCertName = 'azureVPNClient.' + $count

    $rootCert | New-AzureVPNClientCertificate -subject $clientCertName | Export-AzureVPNCertificate -path $exportPath -pfx -password $pfxpassword -removeAfterExport

    $count++
}

$vpnPackage = @{
                    ResourceGroupName = $rgname
                    VirtualNetworkGatewayName = $gw.Name
                    ProcessorArchitecture = Amd64
}

Get-AzureVpnClientPackage @vpnPackage