VMware Cloud Community
mperryukcloud
Contributor
Contributor
Jump to solution

Trying to extract edge service configuration via PowerCLI

I have been using the Get-EdgeGateway to select a target edge gateway in powercli, however when attempting to drill down into the extensiondata i can see some object views like GatewayInterfaces and SyslogServerSettings however when attempting to drill down on EdgeGatewayServiceConfiguration, the result is blank so i cannot seemingly go any further. Has anyone been able to do this

 

$Edge = Get-EdgeGateway -name "<my_edge>"

Running #($Edge).ExtensionData.Configuration.EdgeGatewayServiceConfiguration

NetworkService AnyAttr VCloudExtension
-------------- ------- ---------------

and no output is show, despite knowing the edge has many nat and FW rules, i cannot drill down anymore.

 

im porbably doing something stupid.

 

environment is vCloud 10.1 and 10.3 with NSX-v backend with Powercli 12.3

0 Kudos
1 Solution

Accepted Solutions
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi.

Get-EdgeGateway has not been updated for a long time and is out of date for your task.
In Powershell you can use Api Invoke-WebRequest and Invoke-RestMethod or method 'system.net.webclient'.
Here is an example of getting some properties (in xml):

 

$EdgeGateway = Search-Cloud -QueryType EdgeGateway -name 'Edge-Test80'
$Edgeview = $EdgeGateway | Get-Ciview
$webclient = New-Object system.net.webclient
$webclient.Headers.Add("x-vcloud-authorization",$EdgeView.Client.SessionKey)
$webclient.Headers.Add("accept","application/*+xml;version=34.0")
$edgeview.id -match "(?<=urn:vcloud:gateway:).*"
$edgeID = $Matches[0]
$requrl = "https://" + $global:DefaultCIServers.name + "/network/edges/" + $edgeID
[xml]$EGWConfXML = $webclient.DownloadString($requrl)
$NATRules = $EGWConfXML.edge.features.nat.natrules.natrule
$IpsecRules = $EGWConfXML.edge.features.ipsec
$RoutesRules = $EGWConfXML.edge.features.routing
$L2vpnRules = $EGWConfXML.edge.features.l2Vpn
$SslvpnRules = $EGWConfXML.edge.features.sslvpnConfig

 

 

View solution in original post

2 Replies
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi.

Get-EdgeGateway has not been updated for a long time and is out of date for your task.
In Powershell you can use Api Invoke-WebRequest and Invoke-RestMethod or method 'system.net.webclient'.
Here is an example of getting some properties (in xml):

 

$EdgeGateway = Search-Cloud -QueryType EdgeGateway -name 'Edge-Test80'
$Edgeview = $EdgeGateway | Get-Ciview
$webclient = New-Object system.net.webclient
$webclient.Headers.Add("x-vcloud-authorization",$EdgeView.Client.SessionKey)
$webclient.Headers.Add("accept","application/*+xml;version=34.0")
$edgeview.id -match "(?<=urn:vcloud:gateway:).*"
$edgeID = $Matches[0]
$requrl = "https://" + $global:DefaultCIServers.name + "/network/edges/" + $edgeID
[xml]$EGWConfXML = $webclient.DownloadString($requrl)
$NATRules = $EGWConfXML.edge.features.nat.natrules.natrule
$IpsecRules = $EGWConfXML.edge.features.ipsec
$RoutesRules = $EGWConfXML.edge.features.routing
$L2vpnRules = $EGWConfXML.edge.features.l2Vpn
$SslvpnRules = $EGWConfXML.edge.features.sslvpnConfig

 

 

mperryukcloud
Contributor
Contributor
Jump to solution

I did wonder if it was due to not being worked on

thanks for the reply, gave me what i needed and more as it was so easy to follow, i added FW rules and SSH config to the output variables.

 

Thanks a million and saved me so much time.

0 Kudos