-
Notifications
You must be signed in to change notification settings - Fork 0
/
Query-NCL3Fconnections.ps1
45 lines (31 loc) · 1.53 KB
/
Query-NCL3Fconnections.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
39
40
41
42
43
44
45
$uri = "REST endpoint"
$moduleName = "networkcontroller"
$connectionType = "L3"
function Import-ModuleIfNotAlreadyImported {
param ([String]$Name)
$isImported = Get-Module | Where-Object {$_.Name -eq $Name}
if (!$isImported) {
Import-Module $Name
}
}
function Query-NCL3Fconnections {
param (
[String]$VmNetworkName,
[String]$URI
)
$virtualGatewayArray = Get-NetworkControllerVirtualGateway -ConnectionUri $uri
$connectionType = "L3"
foreach ($virtualGateway in $virtualGatewayArray) {
$L3FConnectionsArray = ((Get-NetworkControllerVirtualGatewayNetworkConnection -ConnectionUri $uri `
-VirtualGatewayId $virtualGateway.ResourceId).Properties | `
Where-Object {$_.ConnectionType -eq $connectionType})
foreach ($L3FConnection in $L3FConnectionsArray) {
$logicalNetworkResourceId = ($L3FConnection.L3Configuration.VlanSubnet.ResourceRef -split ("/"))[2]
$L3FConnectionResourceName = (Get-NetworkControllerLogicalNetwork -ConnectionUri $uri -ResourceId $logicalNetworkResourceId).ResourceMetadata.ResourceName
$L3FConnection | Add-Member -MemberType NoteProperty -Name "L3 connection name" -Value $L3FConnectionResourceName
$L3FConnection
}
}
}
Import-ModuleIfNotAlreadyImported -Name $moduleName
Query-NCL3Fconnections -VmNetworkName $vmNetworkName -URI $uri